android 引用jar的r文件,正确的方法来处理Android库的ant构建. Build从jar文件中排除R.class...
目前遇到的問題是我們使用ant生成的構建版本不包含R.class文件.看一下ADT build.xml,我看到了這個:
...
includes="**/*.class"
excludes="${project.app.package.path}/R.class ${project.app.package.path}/R$*.class ${project.app.package.path}/BuildConfig.class"/>
excludes="**/*.java ${android.package.excludes}" />
目前構建抓取classes.jar文件,但正如您在上面看到的,這不包括R.class文件,因此當庫嘗試獲取外部化字符串時,它會在NoClassDefFoundError上爆炸
Important change:
We have changed the way Library Projects generate and package R classes:
The R class is not packaged in the jar output of Library Projects anymore.
Library Project do not generate the R class for Library Projects they depend on. Only main application projects generates the Library R classes alongside their own.
This means that library projects cannot import the R class from another library project they depend on. This is not necessary anyway, as their own R class includes all the necessary resources.
Note that app projects can still import the R classes from referenced Library Projects, but again, this is not needed as their own R classes include all the resources.
那么,鑒于此,打包Android庫項目的正確方法是什么?
更新2:
因此,我們通過手動將R.class和R $* .class文件打包到jar中來解決此問題.
我不知道這是否是打包Android庫的“正確”方式,因為ADT構建腳本將這些刪除.如果沒有人建議采用更“正確”的方式來做到這一點,我會將此作為答案.
總結
以上是生活随笔為你收集整理的android 引用jar的r文件,正确的方法来处理Android库的ant构建. Build从jar文件中排除R.class...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android透明视频教程,安卓透明教程
- 下一篇: 鸿蒙是安卓换皮UI,鸿蒙2.0是安卓换皮