Skip to content

build: upgrade AGP to 9.4.0 and Gradle to 9.7.1 - #626

Merged
fortuna merged 1 commit into
build/fix-dependency-verificationfrom
build/upgrade-agp
Sep 15, 2026
Merged

fortuna merged 1 commit into
build/fix-dependency-verificationfrom
build/upgrade-agp

Conversation

@fortuna

@fortuna fortuna commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

What

Upgrades the Android Gradle Plugin from 8.5.1 to 9.4.0 (latest stable) and Gradle from
8.7 to 9.7.1.

Why

AGP 8.5.1 was only tested up to compileSdk = 34. Since #623 compiles against 36, every
build printed:

WARNING: We recommend using a newer Android Gradle plugin to use compileSdk = 36
This Android Gradle plugin (8.5.1) was tested up to compileSdk = 34.

AGP 9.4.0 supports compileSdk 36 natively, so the warning is gone.

What AGP 9 broke, and how it was fixed

Breakage Fix
perf-plugin:1.4.1 uses com.android.build.api.transform.Transform and applicationVariants, both removed in AGP 9. The plugin failed to load. Upgraded the Firebase plugins: google-services 4.4.1 -> 4.5.0, perf-plugin 1.4.1 -> 2.0.2, crashlytics-gradle 2.8.1 -> 3.0.8.
android.defaults.buildfeatures.buildconfig was removed in AGP 9, but LogWrapper reads BuildConfig.DEBUG. buildFeatures { buildConfig = true } in app/build.gradle.
resValues is no longer implicitly enabled, but both build types declare FIREBASE_ENABLED. buildFeatures { resValues = true }.
compileGoBackend read android.sdkDirectory, removed in AGP 9. Use the androidComponents.sdkComponents.sdkDirectory provider.
android.nonFinalResIds=false is no longer honored, so the switch statements over R.id in MainActivity stopped compiling (constant expression required). Converted them to if / else if chains, matching the id == R.id.frame_main check that already existed a few lines below. Dropped the dead flag.

Regenerated lock and verification files

buildscript-gradle.lockfile and gradle/verification-metadata.xml were regenerated for
the new plugin graph.

Important

Regenerating on macOS records only the host aapt2 binary, which would have
reintroduced exactly the bug #625 fixes, just with the platforms swapped. The
aapt2-9.4.0-15978811 linux and windows checksums were therefore added by hand
from the published .sha256 files. As a cross-check, the osx checksum that Gradle
generated matches its published .sha256 exactly.

Verification

  • ./gradlew clean assembleDebug test passes with strict dependency verification.

Not addressed here

The newer lint bundled with AGP 9 reports two additional pre-existing errors that are
unrelated to the build tooling:

  • GestureBackNavigation — MainActivity.onBackPressed() is not called under
    predictive back. This is a real bug affecting in-app back navigation, but fixing
    it properly means migrating to OnBackPressedDispatcher, which needs AppCompat newer
    than the pinned 1.4.0 (it resolves androidx.activity:activity:1.2.4, too old to
    bridge the platform callback). Worth its own PR.
  • NewApi — IntraTileService requires API 24 while minSdk is 21. Guarded at
    runtime by the system, so this is a lint annotation gap.

android.enableJetifier and android.nonTransitiveRClass are deprecated and will be
removed in AGP 10; both are left as TODOs since migrating them needs a separate audit.

AGP 8.5.1 was only tested up to compileSdk 34 and warned on every build
now that the project compiles against 36. AGP 9.4.0 supports it
natively, so the warning is gone.

Required changes:

* Firebase Gradle plugins. perf-plugin 1.4.1 uses the Transform API and
  applicationVariants, both removed in AGP 9, and failed to load at all.
  Upgraded google-services 4.4.1 -> 4.5.0, perf-plugin 1.4.1 -> 2.0.2
  and firebase-crashlytics-gradle 2.8.1 -> 3.0.8.
* buildFeatures. AGP 9 removed android.defaults.buildfeatures.buildconfig
  and no longer enables resValues implicitly, so both are now requested
  in app/build.gradle. LogWrapper reads BuildConfig.DEBUG and the build
  types declare the FIREBASE_ENABLED resValue.
* compileGoBackend used android.sdkDirectory, removed in AGP 9. Use the
  androidComponents.sdkComponents.sdkDirectory provider instead.
* android.nonFinalResIds=false is no longer honored, so the switch
  statements over R.id in MainActivity stopped compiling. Converted them
  to if/else chains, matching the existing id == R.id.frame_main check,
  and dropped the dead flag.
* Regenerated buildscript-gradle.lockfile and verification-metadata.xml.
  The aapt2 linux and windows checksums were added by hand from the
  published .sha256 files, because regenerating on macOS only records
  the host binary.

./gradlew clean assembleDebug test passes with strict dependency
verification.
@fortuna
fortuna removed this pull request from stack #624 September 15, 2026 18:21
@fortuna
fortuna added this pull request to stack #629 September 15, 2026 18:22

@peterwgnd peterwgnd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@fortuna
fortuna merged commit bd7cd01 into master Sep 15, 2026
12 checks passed
@fortuna
fortuna deleted the build/upgrade-agp branch September 15, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants