I'm having trouble with resources in my Android library project. The library project consists of it's source already compiled in .class files in JARs and the resources in the res
folder. The classes were compiled with the --non-constant-id
AAPT option.
In my library project I have:
res/drawable/image1.png
res/drawable/image3.png
In the project dependent on the library project I have:
res/drawable/image2.png
Eclipse creates an R.txt and R.java for each project. So in total there's two R.txt's and two R.java's.
In the library project's R.java, the resource IDs are as such:
image1=0x7f02007c;
image3=0x7f02007d;
A library project means that this R.java file will be merged with the dependent project's R.java yielding a final R.java that looks like:
image1=0x7f02007c;
image2=0x7f02007d;
image3=0x7f02007e;
As expected, the inclusion of image2
shifted the memory locations down by 1 in the final R.java.
The problem: When I reference a resource, like R.drawable.image3
, from the JARs in my library project, it resolves to the ID in the non-merged R.java. For example: R.drawable.image3 = 0x7f02007d
. But 0x7f02007d
actually points to image2
and thus, the wrong resource is returned. I assume I am doing something wrong. Does anyone have any ideas as to what that may be?