Repository navigation
fix(android): update Android template for AGP 9 and API 37.2 - #5906
debanjanbasu wants to merge 4 commits into
Conversation
AGP 9.4.0 and Gradle 9.6.0 support API 37.\nSelect the installed 37.2 platform with compileSdkMinor and\nuse AGP's built-in Kotlin support.
Use per-module BuildConfig and JNI packaging DSL.
|
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"
- }
}| compileSdk = {{ compile_sdk }} | ||
| // API 37's latest platform is published as minor version 37.2. | ||
| if (compileSdk == 37) { | ||
| compileSdkMinor = 2 | ||
| } |
There was a problem hiding this comment.
You should drop the hardcoded minor version.
AGP 9.4.0 builds compileSdk = 37 against platforms;android-37.0, but this block makes the same build fail with Failed to find target with hash string 'android-37.2' when 37.2 is not installed and SDK auto-download is off, or silently download it otherwise.
| compileSdk = {{ compile_sdk }} | |
| // API 37's latest platform is published as minor version 37.2. | |
| if (compileSdk == 37) { | |
| compileSdkMinor = 2 | |
| } | |
| compileSdk = {{ compile_sdk }} |
The geolocation plugin module applied kotlin("android") and
kotlinOptions, which AGP 9's built-in Kotlin rejects. Remove both
and the library targetSdk, and bump AGP to 9.4.0.
Stop forcing compileSdkMinor = 2 for API 37 so compile_sdk = 37
builds against platforms;android-37.0, the AGP default.
Amp-Thread-ID: https://ampcode.com/threads/T-01a13217-b5a6-7065-a56a-fa4cc484512d
Co-authored-by: Amp <amp@ampcode.com>
AGP resolves compileSdk = 37 to platforms;android-37.0. When a newer minor release such as android-37.2 is installed, set compileSdkMinor so the build uses it instead of requiring 37.0. Also set buildToolsVersion to the newest installed stable build-tools. AGP ignores versions below its minimum, so older SDKs keep the default. Previews and release candidates are skipped, and nothing is emitted when no matching package is installed.
Summary
Updates the generated Android project template so
dxcan build Android apps with AGP 9 / Gradle 9.6 and target API 37, whose latest platform is published as minor version 37.2.gen/build.gradle.kts: AGP8.7.0→9.4.0; drops thekotlin-gradle-pluginclasspathgen/app/build.gradle.kts.hbs: setscompileSdkMinor = 2whencompileSdk == 37; addspackaging { jniLibs { useLegacyPackaging = true } }; drops theorg.jetbrains.kotlin.androidplugin and thekotlinOptionsblockgen/app/src/main/AndroidManifest.xml.hbs: dropsandroid:extractNativeLibs, superseded bypackaging.jniLibs.useLegacyPackaginggen/gradle.properties: drops the deprecatedandroid.defaults.buildfeatures.buildconfigflaggen/gradle/wrapper/gradle-wrapper.properties: Gradle9.1.0→9.6.0The Kotlin Android plugin and
kotlinOptionsare dropped because AGP 9 enables built-in Kotlin support by default: https://developer.android.com/build/migrate-to-built-in-kotlincompileSdkis set by the user under[android]inDioxus.toml(compile_sdk), so this stays opt-in: the template only sets the minor version whencompileSdk == 37.