Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle 8 - R file merging not working anymore?

Tags:

android

gradle

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

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?

like image 946
prom85 Avatar asked Dec 06 '25 04:12

prom85


1 Answers

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.

like image 68
Thommy Avatar answered Dec 08 '25 17:12

Thommy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!