Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Gradle 8 – R file merging not working anymore?

In my project I have defined many strings inside a core module. After upgrading to gradle 8 I see that I need to reference R files exactly now.

E.g. if I define a string inside my core module and want to access it from my main module (the main module includes the core module of course) I see following behaviour:

Before

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I could access strings (and all other resources) from the core module inside the main module via com.my.package.main.R and com.my.package.core.R

After

Now I can only access the strings from the exact module anymore so I need to use com.my.package.core.R inside my main module to access strings from the core module…

The same happens for attributes from com.google.android.material.R and androidx.appcompat


Did I miss a migration step? Or should this really be like that?

I think this is a side effect of moving the package names from the AndroidManifest.xml file to the build.gradle.kts as the namespace value but I could not find such a behaviour change documented anywhere

>Solution :

With AGP 8 the default behaviour did change:
See the option android.nonTransitiveRClass in
https://developer.android.com/build/releases/gradle-plugin

android.nonTransitiveRClass

New default: true Old default: false

AGP 8.0 generates R classes for resources defined in the current module only.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading