I\'ve set up the /android project of ZXing 1.7 as a library referenced by my main android app project. As a quick test / proof of concept, I have used the CaptureActivity,
use project->clean..
to regenerate R
Class
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.
public static final class id {
...
public static final int mainmenu_btn_scan=0x7f070028;
...
And in the library project's R class:
public static final class id {
...
public static final int 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/