OssLicensesMenuActivity crashes with Resources$NotFoundException: Resource ID #0x0 in release builds with resource shrinking (AGP 9)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- android
- 領域
- build-system
調査の方向性
まず ./gradlew assembleRelease を使用して AGP 9 でクラッシュを再現し、次に 17.5.1 AAR 内の OssLicensesMenuActivity と zzp.onCreateView のパスを調査します。生成された resources.txt をアプリの res/raw keep XML と比較し、release APK に license_menu_fragment と libraries_social_licenses_license が保持され、ライセンス画面がクラッシュせずに開くことを確認します。
索引モデルが issue の本文から書いたものです。
説明
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-plugin0.13.0 andcom.google.android.gms:play-services-oss-licenses:17.5.1to an app module. - In the release build type set
isMinifyEnabled = trueandisShrinkResources = 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-licenses17.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.
- 主要言語
- Kotlin
- スター
- 526
- フォーク
- 170
- 平均マージ
- 1日 7時間
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
google/play-services-plugins のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
google/play-services-plugins#466 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
google/play-services-plugins#387 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
google/play-services-plugins#362 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
google/play-services-plugins#343 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
google/play-services-plugins#303 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
google/play-services-plugins の issue をすべて見る
似ている issue
-
feature
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
leonlatsch/Photok#816 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
owenlejeune/ArrMatey#417 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
orgzly-revived/orgzly-android-revived#1120 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Tiqr/eduid-app-android#277 ·
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信