Skip to content

build(android): upgrade AGP from 8.x to 9.4.0 - #2111

Merged
jpnurmi merged 8 commits into
masterfrom
jpnurmi/chore/agp-9
Sep 18, 2026
Merged

jpnurmi merged 8 commits into
masterfrom
jpnurmi/chore/agp-9

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

💡 FOSSA blocks releases on AGP 8.7.3's internal test dependencies: com.google.testing.platform artifacts at 0.0.9-alpha02 use the Android SDK license and aren't classified as test-only by FOSSA. AGP 9.4.0 uses com.android.tools.utp:gradle-work-action:32.4.0, whose POM declares Apache 2.0.

Match sentry-java: Gradle 9.7.1, Kotlin 2.3.21, Maven Publish 0.30.0, Dokka 2.0.0, Spotless 8.8.0, Detekt 1.23.8, Develocity 4.5.0, and API 37. Add the VERSION_AGP override.

Gradle 9 removed VersionNumber, breaking the old publishing and native-bundle plugins. Upgrade publishing, apply it before DSL finalization, and copy legacy headers directly into the AAR. Update Craft's source/Javadoc paths and regenerate the wrapper.

Keep Java 8, NDK 27.0.12077973, AAR minCompileSdk=1, and no implicit library targetSdk to preserve hotfix compatibility. Retain the legacy DSL, external Kotlin plugin, and pipeline signing.

Close: #2093

FOSSA blocks releases on AGP `8.7.3`'s internal test dependencies:
`com.google.testing.platform` artifacts at `0.0.9-alpha02` use the
Android SDK license and aren't classified as test-only by FOSSA.
See [#2093](#2093).
AGP `9.4.0` uses `com.android.tools.utp:gradle-work-action:32.4.0`,
whose POM declares Apache 2.0.

Match `sentry-java`: Gradle `9.7.1`, Kotlin `2.3.21`, Maven Publish
`0.30.0`, Dokka `2.0.0`, Spotless `8.8.0`, Detekt `1.23.8`,
Develocity `4.5.0`, and API `37`. Add the `VERSION_AGP` override.

Gradle 9 removed `VersionNumber`, breaking the old publishing and
native-bundle plugins. Upgrade publishing, apply it before DSL
finalization, and copy legacy headers directly into the AAR.
Update Craft's source/Javadoc paths and regenerate the wrapper.

Keep Java `8`, NDK `27.0.12077973`, AAR `minCompileSdk=1`, and no
implicit library `targetSdk` to preserve hotfix compatibility.
Retain the legacy DSL, external Kotlin plugin, and pipeline signing.

API/unit checks, AAR compatibility comparison, release archive,
APK builds, and FOSSA dependency resolution pass locally. Hosted
FOSSA still needs CI verification. Lint flags only outdated
`annotations:23.0.0`, which matches `sentry-java`.
Comment thread ndk/gradlew.bat
Keep warnings-as-errors deterministic while retaining the annotations
version aligned with sentry-java.
@jpnurmi
jpnurmi requested a review from mujacica September 18, 2026 11:29
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.86%. Comparing base (0a136fc) to head (6d32545).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2111      +/-   ##
==========================================
+ Coverage   74.68%   74.86%   +0.18%     
==========================================
  Files         103      103              
  Lines       27449    27449              
  Branches     4966     4966              
==========================================
+ Hits        20500    20551      +51     
+ Misses       5601     5548      -53     
- Partials     1348     1350       +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Cross-cutting build and publication changes require CI and human validation of final release artifacts.

Pull request overview

Upgrades the Android build stack to AGP 9.4.0 to resolve FOSSA license failures while preserving legacy compatibility.

Changes:

  • Upgrades Gradle, AGP, Kotlin, publishing, linting, and API levels.
  • Updates publishing and AAR header packaging for Gradle 9.
  • Preserves Java 8, NDK, SDK, and legacy DSL behavior.
File summaries
File Description
ndk/settings.gradle Upgrades Develocity.
ndk/sample/build.gradle.kts Targets Android API 37.
ndk/lib/build.gradle.kts Updates Android configuration and AAR packaging.
ndk/gradlew.bat Regenerates the Windows Gradle wrapper script.
ndk/gradlew Regenerates the POSIX Gradle wrapper script.
ndk/gradle/wrapper/gradle-wrapper.properties Upgrades the Gradle distribution.
ndk/gradle.properties Retains legacy Android DSL and SDK behavior.
ndk/build.gradle.kts Upgrades plugins and revises publication packaging.
Review details
  • Files reviewed: 8/9 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread ndk/build.gradle.kts Outdated

@runningcode runningcode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't seem the right way to fix an issue related to a specific version of a dependency. Gradle has a million ways to change the way dependencies are resolved. See here for more details. https://docs.gradle.org/current/userguide/resolution_rules.html

But as your resident Gradle expert I do suggest that you update to the latest Gradle version!

Comment thread ndk/build.gradle.kts Outdated
Comment thread ndk/build.gradle.kts Outdated
Comment thread ndk/build.gradle.kts

subprojects {
// keep Java and Kotlin bytecode compatible with existing consumers
val javaVersion = JavaVersion.VERSION_1_8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i'm sad that the bad practices from sentry-java are being copied here. we should try to remove this or move it to a build-logic plugin (docs)

I understand why this is needed from a compatibilty perspective though as Google raised the default away from the deprecated java 8 to java 11. We should also follow google's pattern and raise it to java 11 because once google raises it, nobody else will need it.

Comment thread ndk/build.gradle.kts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8f243e2. Configure here.

Comment thread ndk/lib/build.gradle.kts Outdated
Comment thread ndk/lib/build.gradle.kts Outdated
compileSdk = 35
compileSdk = 37
// retain AGP 8.7.3's default NDK to avoid changing the compiler and libc++ in a hotfix
ndkVersion = System.getenv("ANDROID_NDK") ?: "27.0.12077973"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

where do we set the ANDROID_NDK env variable? or is that needed for local testing?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Used by integration tests:

def get_android_config():
"""
Returns Android toolchain CMake options if ANDROID_API and ANDROID_NDK
environment variables are set.
"""
if not (os.environ.get("ANDROID_API") and os.environ.get("ANDROID_NDK")):
return {}
toolchain = "{}/ndk/{}/build/cmake/android.toolchain.cmake".format(
os.environ["ANDROID_HOME"], os.environ["ANDROID_NDK"]
)
return {
"CMAKE_TOOLCHAIN_FILE": toolchain,
"ANDROID_ABI": os.environ.get("ANDROID_ARCH") or "x86",
"ANDROID_NATIVE_API_LEVEL": os.environ["ANDROID_API"],
}

Locally and in the CI:

- name: Android (API 21, NDK 23)
os: ubuntu-latest
ANDROID_API: 21
ANDROID_NDK: 23.2.8568313
ANDROID_ARCH: x86_64
- name: Android (API 26, NDK 27)
os: ubuntu-latest
ANDROID_API: 26
ANDROID_NDK: 27.3.13750724
ANDROID_ARCH: x86_64
- name: Android (API 31, NDK 27)
os: ubuntu-latest
ANDROID_API: 31
ANDROID_NDK: 27.3.13750724
ANDROID_ARCH: x86_64
- name: Android (API 35, NDK 29)
os: macos-15-large
ANDROID_API: 35
ANDROID_NDK: 29.0.14206865
ANDROID_ARCH: x86_64
- name: Android (API 36, NDK 30 + asan)
os: ubuntu-latest
ANDROID_API: 36
ANDROID_NDK: 30.0.16138531
ANDROID_ARCH: x86_64
RUN_ANALYZER: asan

@jpnurmi
jpnurmi merged commit b72a03e into master Sep 18, 2026
112 of 114 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/chore/agp-9 branch September 18, 2026 14:49
jpnurmi added a commit that referenced this pull request Sep 18, 2026
* build(android): Upgrade AGP to replace flagged test tooling

FOSSA blocks releases on AGP `8.7.3`'s internal test dependencies:
`com.google.testing.platform` artifacts at `0.0.9-alpha02` use the
Android SDK license and aren't classified as test-only by FOSSA.
See [#2093](#2093).
AGP `9.4.0` uses `com.android.tools.utp:gradle-work-action:32.4.0`,
whose POM declares Apache 2.0.

Match `sentry-java`: Gradle `9.7.1`, Kotlin `2.3.21`, Maven Publish
`0.30.0`, Dokka `2.0.0`, Spotless `8.8.0`, Detekt `1.23.8`,
Develocity `4.5.0`, and API `37`. Add the `VERSION_AGP` override.

Gradle 9 removed `VersionNumber`, breaking the old publishing and
native-bundle plugins. Upgrade publishing, apply it before DSL
finalization, and copy legacy headers directly into the AAR.
Update Craft's source/Javadoc paths and regenerate the wrapper.

Keep Java `8`, NDK `27.0.12077973`, AAR `minCompileSdk=1`, and no
implicit library `targetSdk` to preserve hotfix compatibility.
Retain the legacy DSL, external Kotlin plugin, and pipeline signing.

API/unit checks, AAR compatibility comparison, release archive,
APK builds, and FOSSA dependency resolution pass locally. Hosted
FOSSA still needs CI verification. Lint flags only outdated
`annotations:23.0.0`, which matches `sentry-java`.

* Disable dependency update lint

Keep warnings-as-errors deterministic while retaining the annotations
version aligned with sentry-java.

* gradlew spotlessApply

* fix ndk 30 + asan

* respect ANDROID_NDK in Gradle configuration

* drop VERSION_AGP

* plugins & separators

* fix ANDROID_NDK (can be a path)
jpnurmi added a commit that referenced this pull request Sep 19, 2026
* fix(ratelimiter): Respect envelope item categories (#2109)

* fix(ratelimiter): Respect envelope item categories

Honor feedback, log, metric, and attachment limits independently of
errors. Preserve attachment dependencies and minidump error limits, and
keep the longest backoff when limits overlap.

* Update CHANGELOG.md

* fix review finding

* ci(release): add missing merge target (#2110)

`master` already contains breaking changes for `0.17`, so the upcoming
`0.16.7` hotfix must ship from `0.16.x`. Selecting that branch only
changes the release source; Craft still defaults to merging the release
commit into `master` which will conflict.

Add the optional `merge_target` input following the _Release and
Versioning_ dev docs [1]. This lets hotfix releases merge their version
bump and changelog back into the hotfix branch, completing the release
process without conflicts with `master`. The default branch remains
the fallback when the input is omitted.

[1] https://develop.sentry.dev/sdk/getting-started/standards/release-versioning/#merge-target

* build(android): upgrade AGP from 8.x to 9.4.0 (#2111)

* build(android): Upgrade AGP to replace flagged test tooling

FOSSA blocks releases on AGP `8.7.3`'s internal test dependencies:
`com.google.testing.platform` artifacts at `0.0.9-alpha02` use the
Android SDK license and aren't classified as test-only by FOSSA.
See [#2093](#2093).
AGP `9.4.0` uses `com.android.tools.utp:gradle-work-action:32.4.0`,
whose POM declares Apache 2.0.

Match `sentry-java`: Gradle `9.7.1`, Kotlin `2.3.21`, Maven Publish
`0.30.0`, Dokka `2.0.0`, Spotless `8.8.0`, Detekt `1.23.8`,
Develocity `4.5.0`, and API `37`. Add the `VERSION_AGP` override.

Gradle 9 removed `VersionNumber`, breaking the old publishing and
native-bundle plugins. Upgrade publishing, apply it before DSL
finalization, and copy legacy headers directly into the AAR.
Update Craft's source/Javadoc paths and regenerate the wrapper.

Keep Java `8`, NDK `27.0.12077973`, AAR `minCompileSdk=1`, and no
implicit library `targetSdk` to preserve hotfix compatibility.
Retain the legacy DSL, external Kotlin plugin, and pipeline signing.

API/unit checks, AAR compatibility comparison, release archive,
APK builds, and FOSSA dependency resolution pass locally. Hosted
FOSSA still needs CI verification. Lint flags only outdated
`annotations:23.0.0`, which matches `sentry-java`.

* Disable dependency update lint

Keep warnings-as-errors deterministic while retaining the annotations
version aligned with sentry-java.

* gradlew spotlessApply

* fix ndk 30 + asan

* respect ANDROID_NDK in Gradle configuration

* drop VERSION_AGP

* plugins & separators

* fix ANDROID_NDK (can be a path)

* feat: allow initial scope configuration before crash handler startup (#2087)

* feat: allow tags before crash handler startup

* docs: clarify initial tags option

* Update CHANGELOG.md with new features and deprecations

* test: gate initial tags fast-fail on WER

* feat: generalize initial scope configuration

* chore: credit external contributor (#2088)

* chore: add faulty 0.16.7 note to changelog

* release: 0.16.8

* ci(codeql): Compile Android Java sources for analysis

The root compileJava task has no sources. Successful Java scans only
captured Gradle's generated project accessors, leaving the SDK's Java
sources unanalyzed.

Upgrading Gradle from 8.9 to 9.7.1 moved those accessors into Gradle
User Home, which setup-gradle restores from cache. Once cached, no
Java compilation remained for CodeQL to observe, so analysis failed
with exit code 32.

Run compileReleaseJavaWithJavac to compile the library and sample.
Disable the build cache and force task execution so CodeQL observes
compilation even when Gradle state is restored.

Validated release Java compilation for both modules with Java 17.

---------

Co-authored-by: Nathan White <whitenathan@microsoft.com>
Co-authored-by: sdk-maintainer-bot[bot] <271021537+sdk-maintainer-bot[bot]@users.noreply.github.com>
Co-authored-by: getsentry-bot <bot@sentry.io>
Co-authored-by: sentry-release-bot[bot] <180476844+sentry-release-bot[bot]@users.noreply.github.com>
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.

CI: License Compliance checks fail

4 participants