Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Resource references break after moving to non-transitive R classes

Errorandroid.nonTransitiveRClass=true

Short answer

With non-transitive R classes, a module's R holds only that module's own resources. Code that reads a library's string or layout through the app's R no longer compiles. Run Refactor, Migrate to Non-Transitive R Classes, or rewrite the references to the owning module's R. The setting is on by default since Android Gradle plugin 8.0.

  • Applies to Android Gradle plugin 8.x and 9.x, Android Studio 2026, Gradle 8.x and 9.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Look at the flag in gradle.properties. No line means you are on the AGP default, which is on since version 8.0.

    grep -n "nonTransitiveRClass" gradle.properties
  2. 2Match what you see, then jump to its fix

    1. 1Compile errors start in the app module right after upgrading AGP or turning the flag on, on references to resources that live in a library moduleCode reaches a library's resources through the app's R classFix
    2. 2The project built before upgrading Android Gradle plugin to 8.0 or newer and has no nonTransitiveRClass lineAn upgrade to AGP 8 flipped the default while the code was written for the old behaviourFix

What does the error look like?

  • android.nonTransitiveRClass=true
  • Refactor > Migrate to Non-Transitive R Classes

Cause 1 of 2

Code reaches a library's resources through the app's R class

1Check

Each module's R class only lists resources defined in that module, not those of its dependencies. Find where the resource is declared and compare it with the module whose R you used.

grep -rn "name=\"my_title\"" --include=*.xml .

2Fix

Use Android Studio's refactoring, which rewrites the references and the namespace for you, then build. It lives under Refactor in the menu bar.

# Android Studio
Refactor > Migrate to Non-Transitive R Classes
# then
./gradlew assembleDebug

3Verify

The app module compiles with the flag on.

./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 2

An upgrade to AGP 8 flipped the default while the code was written for the old behaviour

1Check

AGP 8.0 changed android.nonTransitiveRClass from false to true, so a project with no explicit line switches behaviour on upgrade.

grep -n "com.android.application\|com.android.library" build.gradle* app/build.gradle*

2Fix

To get a working build today, write the old value into gradle.properties, then migrate in your own time and delete the line afterwards.

# gradle.properties
android.nonTransitiveRClass=false

3Verify

Sync and build; the old references compile again.

./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Keep the flag at its default and fix references when a module is added, instead of switching it off.
  • Reference a resource through the R class of the module that declares it.
  • Run a full assemble in CI after each AGP upgrade.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.