Android Drawable Resource Id Conflict?
Solution 1:
Ok, it seems like the Android platform has a few wrinkles when using library projects. I noticed that the R class of my project and the R class of the ZXIng library project were conflicting all over the place e.g.
publicstaticfinalclassid {
...
publicstaticfinalint mainmenu_btn_scan=0x7f070028;
...
And in the library project's R class:
publicstaticfinalclassid {
...
publicstaticfinalint share_app_button=0x7f070028;
...
This explains how a UI element from my activity was being picked up by an activity in the library project. Android will give priority to resources ids in the main project.
This excellent article gave the solution: http://blog.blackmoonit.com/2010/12/android-sharing-resources-in-eclipse.html
In CaptureActivity (the activity I was calling in the library), I replaced
viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
With this
viewfinderView = (ViewfinderView) findViewById(
getResources().getIdentifier("viewfinder_view", "id", getPackageName()) );
This fixed the issue, although I'll need to go through and replace all direct id references with getIndentifier() to ensure there aren't any other conflicts. Not an ideal solution. It feels like there ought to be some fairly straightforward extension to the aapt tool to ensure that the ids between R classes don't conflict.
See here for more info: http://devmaze.wordpress.com/2011/05/22/android-application-android-libraries-and-jar-libraries/
Solution 2:
use project->clean..
to regenerate R
Class
Post a Comment for "Android Drawable Resource Id Conflict?"