Describe the bug
OssLicensesMenuActivity (v1) crashes on launch in release builds that have resource shrinking enabled (isMinifyEnabled = true + isShrinkResources = true) under AGP 9. Debug builds are unaffected because resource shrinking is off there.
Fatal Exception: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.ResourcesImpl.getValue (ResourcesImpl.java:300)
at android.content.res.Resources.loadXmlResourceParser (Resources.java:2575)
at android.content.res.Resources.getLayout (Resources.java:1289)
at android.view.LayoutInflater.inflate (LayoutInflater.java:460)
at com.google.android.gms.oss.licenses.zzp.onCreateView (com.google.android.gms:play-services-oss-licenses@@17.5.1:2)
...
at androidx.fragment.app.FragmentActivity.onStart (FragmentActivity.java:348)
It reproduced for every user who opened the licenses screen in our Play Store build, across device models and OS versions.
To Reproduce
- Apply
com.google.android.gms.oss-licenses-plugin 0.13.0 and com.google.android.gms:play-services-oss-licenses:17.5.1 to an app module.
- In the release build type set
isMinifyEnabled = true and isShrinkResources = true.
- Build with AGP 9 (
./gradlew assembleRelease) and install the release APK.
startActivity(Intent(context, OssLicensesMenuActivity::class.java)).
- The activity crashes on start with the stack trace above.
Expected behavior
OssLicensesMenuActivity works in release builds with resource shrinking enabled, without the app having to know about the library's internal resource names.
Screenshots
N/A (crash on launch).
Desktop (please complete the following information):
- Gradle version: 9.7.0 (AGP 9.3.1)
- Android Studio version: Quail 3 | 2026.1.3 Patch 1
- Plugin name and version: OSS Licenses plugin 0.13.0 /
play-services-oss-licenses 17.5.1
Additional context
Our analysis of the 17.5.1 AAR points at resource shrinking removing layouts that the library only looks up dynamically.
The Fragment that OssLicensesMenuActivity hosts (zzp in 17.5.1) resolves its layout by name through Resources.getIdentifier() in onCreateView, rather than through an R constant:
inflater.inflate(
resources.getIdentifier("license_menu_fragment", "layout", packageName),
container, false)
Since nothing references R.layout.license_menu_fragment as a constant, the shrinker drops the layout, getIdentifier() returns 0, and LayoutInflater.inflate(0, ...) throws Resource ID #0x0.
This looks like a regression tied to AGP 9. The same app built with AGP 8.x and android.r8.optimizedResourceShrinking=true kept license_menu_fragment in the APK. After upgrading to AGP 9, where optimized resource shrinking is the standard pipeline, it is dropped — the getIdentifier() string-constant heuristic that safe mode relies on no longer marks these resources as reachable.
As a workaround we added a keep file to our own app module:
<!-- app/src/main/res/raw/<your_package>_keep.xml -->
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="
@layout/license_menu_fragment,
@layout/libraries_social_licenses_license,
@id/license,
@id/license_list" />
With that in place resources.txt reports both layouts as reachable from keep xml file and the licenses screen works again.
Describe the bug
OssLicensesMenuActivity(v1) crashes on launch in release builds that have resource shrinking enabled (isMinifyEnabled = true+isShrinkResources = true) under AGP 9. Debug builds are unaffected because resource shrinking is off there.It reproduced for every user who opened the licenses screen in our Play Store build, across device models and OS versions.
To Reproduce
com.google.android.gms.oss-licenses-plugin0.13.0 andcom.google.android.gms:play-services-oss-licenses:17.5.1to an app module.isMinifyEnabled = trueandisShrinkResources = true../gradlew assembleRelease) and install the release APK.startActivity(Intent(context, OssLicensesMenuActivity::class.java)).Expected behavior
OssLicensesMenuActivityworks in release builds with resource shrinking enabled, without the app having to know about the library's internal resource names.Screenshots
N/A (crash on launch).
Desktop (please complete the following information):
play-services-oss-licenses17.5.1Additional context
Our analysis of the 17.5.1 AAR points at resource shrinking removing layouts that the library only looks up dynamically.
The
FragmentthatOssLicensesMenuActivityhosts (zzpin 17.5.1) resolves its layout by name throughResources.getIdentifier()inonCreateView, rather than through anRconstant:Since nothing references
R.layout.license_menu_fragmentas a constant, the shrinker drops the layout,getIdentifier()returns0, andLayoutInflater.inflate(0, ...)throwsResource ID #0x0.This looks like a regression tied to AGP 9. The same app built with AGP 8.x and
android.r8.optimizedResourceShrinking=truekeptlicense_menu_fragmentin the APK. After upgrading to AGP 9, where optimized resource shrinking is the standard pipeline, it is dropped — thegetIdentifier()string-constant heuristic that safe mode relies on no longer marks these resources as reachable.As a workaround we added a keep file to our own app module:
With that in place
resources.txtreports both layouts asreachable from keep xml fileand the licenses screen works again.