Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

OssLicensesMenuActivity crashes with Resources$NotFoundException: Resource ID #0x0 in release builds with resource shrinking (AGP 9)

クローズ
#460 コメント 1 件 リアクション 5 件 担当者 0 名 GitHub で見る

メンテナーはふだん 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

  1. 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.
  2. In the release build type set isMinifyEnabled = true and isShrinkResources = true.
  3. Build with AGP 9 (./gradlew assembleRelease) and install the release APK.
  4. startActivity(Intent(context, OssLicensesMenuActivity::class.java)).
  5. 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.

主要言語
Kotlin
スター
526
フォーク
170
平均マージ
1日 7時間
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

google/play-services-plugins のほかの issue

google/play-services-plugins の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。