简体   繁体   中英

Android gradle plugin v3.3.0 -> can't find R$raw when using proguard

Just updated to Android gradle plugin version 3.3.0

We have the following setup (not sure which are important):

  • Application project (app) with 3 library modules (data, domain, utils)

  • Databinding enabled ( databinding.enabled true )

  • Proguard enabled( proguardFiles 'proguard-rules.pro' )

When I build the app using:

./gradlew assembleDevRelease

I get the following error:

can't find referenced class my.package.data.R$raw

When I build the app using:

./gradlew :app:assembleDevRelease

The app builds fine, generates an obfuscated *.apk which I can install

Question:

  • What's the difference between assembleRelease and :app:assembleRelease

- 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.

  • What changed in android gradle plugin 3.3.0 that caused the task assembleRelease to break? We use assembleRelease everywhere in our CI pipelines to build our apks.

  • Any suggestions how we can make 'assembleRelease' working again? (update Proguard config?, enabling R8?)

What's the difference between assembleRelease and :app:assembleRelease

The former runs the assembleRelease task on all modules relative to current level. The latter runs it on the app module only (and its dependencies).

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.

The question does not have enough info to say for sure, but there are a number of changes listed in the release notes . For example, this issue might be related to:

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 intermediate R.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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM