Repository navigation
Description
Steps to reproduce
Any Android plugin that sets compileSdkExtension triggers a spurious compileSdk warning in consuming apps, because Flutter's Gradle tooling cannot parse the resulting platform hash string.
-
In an Android plugin's
android/build.gradle, set both acompileSdkand acompileSdkExtension:android { compileSdk = 36 compileSdkExtension = 19 }
(This is not exotic — it is mandatory for anything depending on
androidx.health.connect:connect-client:1.2.0-alpha03, whose AAR metadata declaresminCompileSdk=36/minCompileSdkExtension=19.) -
Consume that plugin from an app with a higher plain
compileSdk, e.g.compileSdk = 37. -
flutter build apk --release
Expected results
No warning. The plugin compiles against API 36 (extension 19); the app compiles against API 37. The app's compileSdk is not lower than the plugin's, so there is nothing to warn about.
Actual results
Your project is configured to compile against Android SDK 37, but the following plugin(s) require to be compiled against a higher Android SDK version:
- health_connector_hc_android compiles against Android SDK 2147483647
Fix this issue by compiling against the highest Android SDK version (they are backward compatible).
Add the following to .../android/app/build.gradle.kts:
android {
compileSdk = 2147483647
...
}
2147483647 is Int.MAX_VALUE, and the suggested fix is impossible to apply.
Root cause
FlutterPluginUtils.getCompileSdkFromProject extracts the compile SDK by blindly stripping the first 8 characters (android-) off AGP's platform hash string:
internal fun getCompileSdkFromProject(project: Project): String =
getLegacyAndroidExtension(project).compileSdkVersion!!.substring(8)When compileSdkExtension is set, AGP's AndroidVersion.getPlatformHashString() appends the extension level, so compileSdkVersion is "android-36-ext19" rather than "android-36". substring(8) therefore yields "36-ext19".
That value then flows into two places, both of which mishandle it:
1. detectLowCompileSdkVersionOrNdkVersion — falls back to Int.MAX_VALUE:
val pluginCompileSdkVersion: Int =
getCompileSdkFromProject(pluginProject).toIntOrNull() ?: Int.MAX_VALUE"36-ext19".toIntOrNull() is null, so the plugin is treated as requiring API 2147483647. The comment on L698-699 shows the fallback was intended for preview SDKs (android-Baklava); the -extNN suffix was not considered.
2. PluginHandler — string-compares the raw value:
val projectCompileSdkVersion: String = getCompileSdkFromProject(project)
val pluginCompileSdkVersion: String = getCompileSdkFromProject(pluginProject)
if (pluginCompileSdkVersion > projectCompileSdkVersion) { ... }This produces its own wrong answers for extension strings — e.g. "36-ext19" > "36" is true, so a plugin on API 36 ext 19 warns against an app on plain API 36. (The existing TODO on L126-128 already flags this comparison as unsound for preview versions.)
Impact
The warning is cosmetic — logPluginCompileSdkWarnings is logger-only and the build succeeds — but it is unactionable and misleading. Plugin authors who depend on any AAR requiring an SDK extension have no way to silence it: removing compileSdkExtension makes AGP's AAR metadata check fail, and keeping it produces this warning on every consumer build. It has already led to churn in at least one plugin repo trying to "fix" a bug that isn't theirs.
Suggested fix
Parse the extension suffix instead of discarding it. For the API-level comparison, the base API level is the meaningful number:
internal fun getCompileSdkFromProject(project: Project): String =
getLegacyAndroidExtension(project).compileSdkVersion!!
.substring(8)
.substringBefore("-ext")That makes "android-36-ext19" yield "36", which parses cleanly and compares correctly in both call sites. If the extension level should participate in the comparison, it would need to be surfaced as a separate field rather than folded into the string.
Flutter Doctor output
flutter doctor -v
[√] Flutter (Channel stable, 3.44.8, on Microsoft Windows [Version 10.0.26200.8973], locale en-IN)
• Flutter version 3.44.8 on channel stable at C:\Users\Devasy\Downloads\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 058e0af2c2 (3 weeks ago), 2026-07-23 10:56:21 -0700
• Engine revision 0cd610717b
• Dart version 3.12.2
• DevTools version 2.57.0
[√] Windows Version (11 Home 64-bit, 25H2, 2009)
[√] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
• Android SDK at C:\Android\SDK
• Platform android-37.0, build-tools 36.0.0
• Java version OpenJDK Runtime Environment Microsoft-11926163 (build 17.0.16+8-LTS)
• All Android licenses accepted.
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2022 17.13.5)
[√] Connected device (3 available)
[√] Network resources
• No issues found!
AGP 8.11.1, Gradle 8.x, Kotlin 2.2.20.
Activity
mbcorona commentedon Aug 14, 2026
Hi @Devasy, thanks for the report. Confirmed from the source.
Routing to the Android team.
Devasy commentedon Aug 14, 2026
Thanks @mbcorona , if it's open to contributions, then I'd love to draft a PR.
camsim99 commentedon Aug 18, 2026
@Devasy Thank you for your interest. Feel free to open a PR to fix this issue!
Devasy commentedon Aug 18, 2026
Following up here: the root cause is already fixed on master, as of #190957 (merged as part of the AGP 9.1.0 migration stack). That PR rewrote
getCompileSdkFromProjectto read AGP's typedcompileSdk: Int?/compileSdkPreview: String?DSL properties directly, instead of parsing the deprecatedcompileSdkVersionplatform-hash string. SincecompileSdknever folds in the extension suffix,"36-ext19".toIntOrNull() ?: Int.MAX_VALUEcan no longer happen — that whole codepath is gone.I couldn't find any test coverage for this specific scenario (a plugin with
compileSdkExtensionset), so I opened #191281 to add a regression test locking this in, rather than a fresh fix. Once that lands this should be safe to close.dragongesa commentedon Aug 20, 2026
do you have any workaround ? @Devasy
Add regression test for plugin compileSdkExtension warning (flutter#1…
github-actions commentedon Sep 14, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.