Repository navigation
fix(android): update Android template for AGP 9 and API 37 - #5906
debanjanbasu wants to merge 1 commit into
Conversation
|
Requesting review from @jkelleyrtp and @ealmloff — fork authors can't request reviewers directly (no push access on this repo), hence the ping. @jkelleyrtp has merged most of the recent Android / CLI-template PRs (#4726 gradle wrapper, #4842 AndroidManifest.xml customization). Change: Android project template → AGP 9.4 / Gradle 9.6; CI: everything green except |
LucaCappelletti94
left a comment
There was a problem hiding this comment.
Rather than tagging maintainers to get a review, you could help by reviewing some of the other open PRs (157 of the 165 open PRs have no review yet). Every PR you review moves the queue forward, including your own.
Also, please don't be a meat proxy. The PR body, the commit messages and the review ping read as forwarded agent output whose claims nobody checked. Your fork PR says the change was "Verified with a release dx build", yet the in-tree plugin example no longer builds, CI never runs Gradle, and commit 80b88b6 carries a literal \n in its message. You should read what the agent produces, verify it, and post only what you can stand behind.
You should migrate the in-tree plugin module to AGP 9, as shown below.
plugins {
- id("com.android.library") version "8.4.2"
- kotlin("android") version "1.9.24"
+ id("com.android.library") version "9.4.0"
}
@@
defaultConfig {
minSdk = 24
- targetSdk = 34
consumerProguardFiles("consumer-rules.pro")
}
@@
targetCompatibility = JavaVersion.VERSION_17
}
-
- kotlinOptions {
- jvmTarget = "17"
- }
}32c1041 to
9c5c784
Compare
|
Before I finalize the Android plugin compatibility policy, should this PR target AGP 10 instead of AGP 9.4? The official roadmap lists AGP 10.0 for late 2026 and describes a broader DSL/API migration, so this would be more than a version bump. Separately, should dx continue normalizing AGP 8-authored source modules for the AGP 9.4 project, or require plugin authors to migrate? I’m holding off on changing that compatibility path pending reviewer guidance. |
|
@LucaCappelletti94, thanks for the direct feedback. You’re right that I should have reviewed other open PRs before asking maintainers for review, and personally checked the claims in this PR instead of forwarding agent-generated text. I’m sorry for that. I’ve addressed your technical feedback and pushed the AGP 9 module changes; the latest CI run is green. I’ll take responsibility for verifying future PR content and contribute to the review queue before requesting maintainer attention. |
LucaCappelletti94
left a comment
There was a problem hiding this comment.
AGP 10 has not yet been released to my knowledge. Google Maven tops out at 9.4.1 stable and 9.5.0-alpha09, and the AGP roadmap asks projects to reach the latest 9.x without deprecation warnings before moving to 10. Therefore, I believe that staying on 9.4 is right for this PR.
Also, I believe that while arguably not the cleanest code, the normalization should stay for the time being. The same roadmap removes the android.builtInKotlin opt-out in AGP 10, so a plugin module that applies kotlin("android") keeps failing there, and stripping it in dx works on both versions. Plugin authors can still migrate their modules, and the in-tree geolocation example shows how.
|
Pushed the SDK defaults as part of this PR:
37 is the newest platform AGP 9.4 knows, and this PR already builds against the newest installed minor of it. Verified here on a machine that only has |
90d3a16 to
3c76850
Compare
- AGP 8.7.0 -> 9.4.0, Gradle 9.1.0 -> 9.6.0. Drop the Kotlin Android plugin and kotlinOptions, since AGP 9 compiles Kotlin itself. - Normalize AGP 8 plugin modules when bundling them: remove the Kotlin Android plugin, kotlinOptions and library targetSdk. - Enable BuildConfig for library modules, replacing the removed android.defaults.buildfeatures.buildconfig flag. - Set compileSdkMinor to the newest installed minor of compile_sdk, and buildToolsVersion to the newest stable build-tools >= 36.0.0. - Default compile_sdk to 37 and target_sdk to 36, the minimum Google Play accepts. - Keep native libraries compressed with useLegacyPackaging and replace the deprecated java.srcDirs. - Migrate the geolocation plugin example to AGP 9.
3c76850 to
00b6fbe
Compare
Summary
Updates the generated Android project for AGP 9.4.0 / Gradle 9.6.0 and API 37.
Template (
packages/cli/assets/android/gen)kotlin-gradle-pluginclasspath.org.jetbrains.kotlin.androidplugin andkotlinOptions, since AGP 9 compiles Kotlin itself (built-in Kotlin).android.defaults.buildfeatures.buildconfigflag by enablingbuildConfigfor library subprojects. The app module already enables it.android:extractNativeLibswithpackaging.jniLibs.useLegacyPackaging = true, so.sofiles stay compressed in the APK. Uncompressed page-aligned libraries, AGP's default for minSdk >= 23, make the distributed APK much larger. The built APK still hasextractNativeLibs=true.java.srcDirs(...)withjava.directories.SDK selection (
packages/cli/src/build/android.rs)compile_sdkdefaults to 37 andtarget_sdkto 36. Since 2026-08-31, Google Play requires new apps and updates to target API 36 (requirements), so the old default of 34 produced apps that cannot be uploaded.compile_sdkis installed, such asplatforms;android-37.2, dx setscompileSdkMinorto it. Otherwise AGP uses its default (android-37.0for 37).buildToolsVersionis set to the newest installed stable build-tools at or above 36.0.0, AGP 9.4's minimum. AGP ignores lower versions with a warning, so in that case dx emits nothing and lets AGP pick.Plugin modules
kotlin("android")/org.jetbrains.kotlin.android,kotlinOptions, and librarytargetSdk. Existing AGP 8 plugins keep building.compileSdk,compileSdkMinorandbuildToolsVersionfrom the generated:appmodule.Testing
CI doesn't run Gradle, so I tested locally (macOS arm64, Android Studio JBR 25, NDK 30.0.16248370, build-tools 36.0.0):
dx build --androidon the geolocation example failed withCannot add extension with name 'kotlin'. On this branch, debug and release builds succeed.compile_sdk = 37, builds succeed with onlyandroid-37.0, onlyandroid-37.2, and both installed. The generated app has nocompileSdkMinor,2, and2respectively.cargo test -p dioxus-cli --bin dx build::androidcovers platform and build-tools selection, including the below-minimum case (onlybuild-tools/35.0.1installed → nobuildToolsVersion), and the AGP 8 normalization.The branch is squashed to one commit on current
main. The tree is unchanged from the reviewed version.