刚刚更新到 Android gradle 插件版本 3.3.0
我们有以下设置(不确定哪个重要):
具有 3 个库模块(数据、域、实用程序)的应用程序项目 (app)
启用数据绑定(bind)(
databinding.enabled true
)Proguard 已启用(
proguardFiles 'proguard-rules.pro'
)
当我使用以下方法构建应用时:
./gradlew assembleDevRelease
我收到以下错误:
找不到引用的类 my.package.data.R$raw
当我使用以下方法构建应用时:
./gradlew :app:assembleDevRelease
应用程序构建良好,生成一个混淆的 *.apk,我可以安装它
问题:
assembleRelease
和:app:assembleRelease
有什么区别?
- 为什么切换到 android gradle plugin 3.3.0 会影响我必须调用哪个任务来构建我的 apk?我们在 CI 管道的任何地方都使用 assembleRelease
来构建我们的 apk。
导致任务
assembleRelease
中断的 android gradle 插件 3.3.0 发生了什么变化?我们在 CI 管道的任何地方都使用assembleRelease
来构建我们的 apk。有什么建议可以让“assembleRelease”重新工作吗? (更新 Proguard 配置?启用 R8?)
最佳答案
What's the difference between
assembleRelease
and:app:assembleRelease
前者在当前级别的所有模块上运行assembleRelease
任务。后者仅在 app
模块(及其依赖项)上运行它。
Why does switching to android gradle plugin 3.3.0 affect which task I have to call to build my apk? We use
assembleRelease
everywhere in our CI pipelines to build our apks.
该问题没有足够的信息可以肯定地说,但是 release notes 中列出了一些更改。 .例如,此问题可能与:
Faster R class generation for library projects: Previously, the Android Gradle plugin would generate an
R.java
file for each of your project's dependencies and then compile those R classes alongside your app's other classes. The plugin now generates a JAR containing your app's compiled R class directly, without first building intermediateR.java
classes. This optimization may significantly improve build performance for projects that include many library subprojects and dependencies, and improve the indexing speed in Android Studio.
关于Android gradle plugin v3.3.0 -> 使用 proguard 时找不到 R$raw,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54216820/