日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android 引用jar的r文件,正确的方法来处理Android库的ant构建. Build从jar文件中排除R.class...

發(fā)布時間:2025/3/20 Android 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 引用jar的r文件,正确的方法来处理Android库的ant构建. Build从jar文件中排除R.class... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

目前遇到的問題是我們使用ant生成的構(gòu)建版本不包含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}" />

目前構(gòu)建抓取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文件打包到j(luò)ar中來解決此問題.

我不知道這是否是打包Android庫的“正確”方式,因為ADT構(gòu)建腳本將這些刪除.如果沒有人建議采用更“正確”的方式來做到這一點,我會將此作為答案.

總結(jié)

以上是生活随笔為你收集整理的android 引用jar的r文件,正确的方法来处理Android库的ant构建. Build从jar文件中排除R.class...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。