当库项目被添加的Android R.java行为 [英] android R.java behavior when a library project is added
问题描述
我用我的应用程序zxing的酒吧code扫描库。所以我已经设置zxing项目作为库和添加该库到我的项目(属性 - > Android的 - >添加库)
I am using zxing library for barcode scanning in my application. So i have set zxing project as a library and adding that library to my project ( properties -> android -> add library )
添加,当我建立code库项目后,我看到有我的项目中创建了两个R.java文件。
After adding the library project when i build the code , i see that there are two R.java files created within my project.
一是路径下:根\\ COM \\谷歌\\ zxing \\客户端\\ android的
One is under the path :gen\com\google\zxing\client\android
和其他:根\\ myproject的
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 one has resource variables only from my project. When a new layout or resource variable is added its getting updated in both files
所以,我的疑惑是:
1.为什么有两个R.java文件
2.有没有办法,我可以停止生成一个与所有库项目变量
So my doubts are : 1. why there are two R.java files 2. Is there a way i can stop generating the one with all library project variables
由于这种行为我跑了很奇怪的问题,这是很难调试。
Because of this behaviour i ran in to very strange issues which was very difficult to debug.
在我zxing库有一个布局捕获当我们试图扫描棒code将被置位。每当我被添加任何布局或名称以字母开始的A/b的任何资源变量我的申请正在给奇怪的行为。和一切工作完美的,当我刚刚更名为布局
后来我发现,它是与该标识在R.java文件捕获。
当我用字母开始定义布局,将在R.java列表捕获,从而为拍摄的ID被改变之前插入。 (有我在其中设置了图书馆作为实际zxing项目的另一个R.java文件。所以好像在我的R.java文件中的ID进行采集和斑马线库R.java应该是相同的)
In my zxing library there is a layout "capture" that will be set when we try to scan a barcode. Whenever i was adding any layout or any resource variable with name starting with letter "a" / "b" my application was giving weird behaviours . And everything worked perfect when i just renamed the layout Later i found that it has something to do with the the id for "capture" in R.java file. When i define a layout with letter starting a, it will be inserted in the R.java list before "capture" and thus the id for capture was changing. ( There is another R.java file in the actual zxing project which i had set as library. So seems like the id for capture in my R.java file and the zxing library R.java should be same )
能否请您解释一下什么是真正发生在这里。
Can you please explain what is really happening here
推荐答案
我觉得你有完整的项目...
I think you include the complete project...
如果这样删除,只导入此文件到您的项目:
If so delete that, and only import this files into your project:
<一个href=\"http://$c$c.google.com/p/zxing/source/browse/trunk#trunk%2Fandroid-integration%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fintegration%2Fandroid%253Fstate%253Dclosed\" rel=\"nofollow\">http://$c$c.google.com/p/zxing/source/browse/trunk#trunk%2Fandroid-integration%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fintegration%2Fandroid%253Fstate%253Dclosed
这就是你所需要的:)
这篇关于当库项目被添加的Android R.java行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!