Skip to content

Plugin with compileSdkExtension triggers bogus "compiles against Android SDK 2147483647" warning #191081

Closed

Description

@Devasy

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.

  1. In an Android plugin's android/build.gradle, set both a compileSdk and a compileSdkExtension:

    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 declares minCompileSdk=36 / minCompileSdkExtension=19.)

  2. Consume that plugin from an app with a higher plain compileSdk, e.g. compileSdk = 37.

  3. 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:

https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/src/main/kotlin/FlutterPluginUtils.kt#L509-L510

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:

https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/src/main/kotlin/FlutterPluginUtils.kt#L726-L727

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:

https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/src/main/kotlin/plugins/PluginHandler.kt#L124-L132

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

  1. added
    platform-androidAndroid applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: buildBuilding flutter applications with the tool
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-androidOwned by Android platform team
    on Aug 14, 2026
  2. mbcorona commented on Aug 14, 2026

    @mbcorona
    Member

    Hi @Devasy, thanks for the report. Confirmed from the source.

    Routing to the Android team.

  3. Devasy commented on Aug 14, 2026

    @Devasy
    ContributorAuthor

    Thanks @mbcorona , if it's open to contributions, then I'd love to draft a PR.

  4. camsim99 commented on Aug 18, 2026

    @camsim99
    Contributor

    @Devasy Thank you for your interest. Feel free to open a PR to fix this issue!

  5. added
    P1High-priority issues at the top of the work list
    triaged-androidTriaged by Android platform team
    on Aug 18, 2026
  6. Devasy commented on Aug 18, 2026

    @Devasy
    ContributorAuthor

    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 getCompileSdkFromProject to read AGP's typed compileSdk: Int? / compileSdkPreview: String? DSL properties directly, instead of parsing the deprecated compileSdkVersion platform-hash string. Since compileSdk never folds in the extension suffix, "36-ext19".toIntOrNull() ?: Int.MAX_VALUE can no longer happen — that whole codepath is gone.

    I couldn't find any test coverage for this specific scenario (a plugin with compileSdkExtension set), 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.

  7. dragongesa commented on Aug 20, 2026

    @dragongesa

    do you have any workaround ? @Devasy

  8. github-actions commented on Sep 14, 2026

    @github-actions

    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 -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: buildBuilding flutter applications with the toolhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions