Android R.java behavior when adding a library project

I am using zxing library to scan barcode in my application. So I installed zxing project as a library and added this library to my project (properties -> android -> add library)

After adding the library project, when I generate the code, I see that there are two R.java files created in my project.

One is under the outline: gen \ com \ google \ zxing \ client \ android

and the other: gen \ myproject

The first one has all the resource variables from the library plus the resource variables in my project. The second option has resource variables only from my project. When a new layout or resource variable is added, its retrieval is updated in both files

So my doubts are: 1. Why are there two R.java files 2. Is there a way I can stop generating one with all the library project variables

Because of this behavior, I ran into very strange problems that were very difficult to debug.

My zxing library has a "capture" layout that will be set when I try to scan a barcode. Whenever I added any layout or any resource variable with a name starting with the letter "a" / "b" my application gave strange behavior. And everything worked fine when I just renamed the layout. Later I found that it had something to do with the id to "capture" in the R.java file. When I define a layout with a letter starting with a, it will be inserted into the R.java list before "grabbing" and hence the ID for the entry will be changed. (There is another R.java file in the actual zxing project that I installed as a library. So it seems that the ID for capture in my R.java file and in the zxing R.java library should be the same)

Could you please explain what is really going on here.

0


source to share


1 answer


I think you have included the complete project ...

If this is the case remove and only import these files into your project:



http://code.google.com/p/zxing/source/browse/trunk#trunk%2Fandroid-integration%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fintegration%2Fandroid%253Fstate%253Dclosed

That's all you need :)

0


source







All Articles