Skip to content

[BUG] Fatal Build Incompatibility: Flutter 3.47.2 + AGP 9.1.0 + Gradle 9.3.1 + Android SDK 37 (Windows) #192111

Description

@bahaa599599

Steps to reproduce

  1. Use Flutter 3.47.2 (Stable) on Windows 11.
  2. Update 'gradle-wrapper.properties' to use Gradle 9.3.1.
  3. Update 'settings.gradle.kts' to use Android Gradle Plugin (AGP) 9.1.0.
  4. Set 'compileSdk' and 'targetSdk' to 36 in 'android/app/build.gradle.kts'.
  5. Use Kotlin 2.4.0 (KGP) and Android SDK 37 command-line tools.
  6. Attempt to enable modern AGP features in 'gradle.properties':
    android.newDsl=true
    android.builtInKotlin=true
  7. Run 'flutter run'.

Expected results

The Flutter build system should successfully orchestrate the build using AGP 9.1.0. It should handle the new Built-in Kotlin compilation model without conflict, correctly resolve task dependencies for sub-modules (like JNI), and successfully initialize internal Gradle services (AndroidLocationsBuildService) on the Windows file system.

Actual results

The project encountered a series of critical failures that prevent any successful build:

  1. SERVICE CREATION FAILURE (Final Blocker):
    'Failed to create service AndroidLocationsBuildService'. The 'AndroidDirectoryCreator' fails to provide a value for 'android.home', preventing the application of 'com.android.application'.

  2. DSL & CLASS CAST EXCEPTION:
    When 'android.newDsl=true', the Flutter Gradle plugin fails with 'java.lang.ClassCastException: ...ApplicationExtensionImpl cannot be cast to ...AbstractAppExtension', as it relies on legacy internal classes removed in AGP 9.0+.

  3. CIRCULAR EVALUATION:
    Gradle 9.3.1 reports 'Circular evaluation detected' when setting 'rootProject.layout.buildDirectory' using standard Flutter template logic. Manual override to 'layout.projectDirectory' was required.

  4. KOTLIN VERSION VALIDATION ERROR:
    Flutter fails to recognize the built-in Kotlin version, reporting: 'Your project's Kotlin version (2.2.10) is lower than Flutter's minimum supported version of 2.2.20', even when KGP 2.4.0 is defined.

  5. DSL NAME COLLISION (Kotlin DSL):
    'signingConfig = signingConfigs.debug' fails with 'Assignment type mismatch' because 'debug' is shadowed by 'NamedDomainObjectProvider'. Requires 'signingConfigs.getByName("debug")'.

  6. JNI PROVIDER FAILURE:
    The task ':jni:compileDebugJavaWithJavac' fails with 'Cannot query the value of this provider because it has no value available', indicating that AGP 9.1.0 is not correctly propagating version providers to sub-modules.

  7. SDK 37 TOOLING MISMATCH:
    'flutter doctor' reports 'Android license status unknown', while the Android SDK 37 CLI reports that the '--licenses' flag is deprecated/removed.

The following plugins are directly involved in the failures or warnings:

  • firebase_core, firebase_auth, cloud_functions, firebase_storage, firebase_app_check (Apply legacy KGP, causing conflicts with AGP 9.1.0).
  • jni_flutter / jni (Task :jni:compileDebugJavaWithJavac fails due to missing provider values).
  • cronet_http, dio, connectivity_plus (Standard dependencies checked during upgrade).
  • geolocator_android, image_picker_android, sqflite_android (Requesting SDK 36+).

Code sample

val sdkDir = localProperties.getProperty("sdk.dir")
if (sdkDir != null) {
System.setProperty("android.home", file(sdkDir).absolutePath)
}

plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "9.1.0" apply false
id("com.google.gms.google-services") version "4.4.2" apply false
}

/////////////////////////////////////////
android {
namespace = "com.example.moon"
compileSdk = 36
buildToolsVersion = "36.0.0"

defaultConfig {
    minSdk = 24
    targetSdk = 36
    versionCode = 1 // Forced to bypass provider issues
    versionName = "1.0.0"
}

buildTypes {
    getByName("release") {
        signingConfig = signingConfigs.getByName("debug")
    }
}

}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

FAILURE: Build failed with an exception.

  • What went wrong:
    An exception occurred applying plugin request [id: 'com.android.application']

Failed to apply plugin 'com.android.internal.application'.
Failed to create service 'AndroidLocationsBuildService_...'.
> Could not create an instance of type com.android.build.gradle.internal.services.AndroidLocationsBuildService.
> Could not create provider for value source AndroidLocationsBuildService.AndroidDirectoryCreator.

  1. Opt-out Strategy: Setting 'android.newDsl=false' and 'android.builtInKotlin=false' resulted in 'Minimum supported Gradle version is 9.3.1' errors and service creation crashes.
  2. Manual Path Injection: Setting 'android.home' and 'android.sdk.path' via System properties in settings.gradle.kts failed to bypass the service initialization error.
  3. Subproject Hardening: Attempted to force namespaces and SDK versions in 'subprojects { afterEvaluate { ... } }' to help legacy plugins, but was blocked by the primary application plugin failure.
  4. Clean Cache: Performed 'flutter clean' and deleted '.gradle' directories multiple times with no change in behavior.

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.47.2, on Microsoft Windows [Version 10.0.26200.9278])
    • Flutter version 3.47.2 at C:\flutter
    • Dart version 3.13.2
    • Java version OpenJDK Runtime Environment Temurin-21.0.6+7
[!] Android toolchain - develop for Android devices (Android SDK version 37.0.0)
    X Android license status unknown.


C:\Users\hp>flutter doctor --android-licenses
WARNING: The SDK Manager CLI tool (sdkmanager) is deprecated. Android CLI will be used instead.
The 'android' binary can also be found in the cmdline-tools directory, and 'android sdk' is the replacement for 'sdkmanager'.
To learn more about the Android CLI and how to use it, see the documentation (https://d.android.com/tools/agents/android-cli)

Activity

  1. added
    in triagePresently being triaged by the triage team
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    needs repro infoAutomated crash report whose cause isn't yet known
    on Sep 1, 2026
  2. mbcorona commented on Sep 1, 2026

    @mbcorona
    Member

    Hi @bahaa599599, thanks for the thorough writeup. The issue is that this is really about seven separate problems in one report, so there's no single fix that could close it. Could you open a focused issue for each one, with a minimal repro?

    A couple you can skip so you don't file them again: the SDK 37 license status one is already fixed in #191487 (see #191554), and signingConfigs.getByName("debug") is just how the Kotlin DSL works, not a bug.

    Also worth knowing, AGP 9.1.0, Gradle 9.3.1, Kotlin 2.4.0 and the newDsl / builtInKotlin flags are all ahead of what 3.47.2 officially supports, so some of this should sort itself out once that support lands.

    The one that looks like a real bug on our side is the AGP 9 newDsl ClassCastException (ApplicationExtensionImpl to AbstractAppExtension). If you file that on its own with a small project, we can act on it.

  3. bahaa599599 commented on Sep 1, 2026

    @bahaa599599
    Author

    Hi @mbcorona

    Update: Confirmed Regression on Minimal Clean Project
    I have successfully reproduced this fatal build failure on a completely new and clean Flutter project (testproject) with no third-party dependencies. This confirms that the issue resides within the dev.flutter.flutter-gradle-plugin and its current inability to handle the strict AGP 9.0+ DSL interfaces.
    Steps taken for Minimal Reproduction:

    1. Created a new project via flutter create testproject.

    2. Updated   gradle-wrapper.properties to Gradle 9.3.1.

    3. Updated   settings.gradle.kts to AGP 9.1.0.

    4. Enabled Modern Mode in   gradle.properties: android.newDsl=true android.builtInKotlin=true

    5. Executed flutter run.

    Result on Clean Project:
    The build fails immediately with the exact same ClassCastException: What went wrong: An exception occurred applying plugin request [id: 'dev.flutter.flutter-gradle-plugin']
    Failed to apply plugin 'dev.flutter.flutter-gradle-plugin'. class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.AbstractAppExtension
    Technical Root Cause:
    As confirmed by the verbose logs, the crash occurs at: com.flutter.gradle.FlutterPlugin.addFlutterTasks(FlutterPlugin.kt:354)
    The plugin is attempting to cast AGP's new ApplicationExtension to the legacy AbstractAppExtension internal class. This is a direct incompatibility with AGP 9.1.0's architecture.
    Request for Guidance on Stable Configuration
    While I wait for a fix for this regression, I would appreciate your advice on the most stable and recommended configuration for Flutter 3.47.2 that avoids these toolchain conflicts while maintaining compatibility with modern plugins (like Firebase).
    What is the currently verified "Safe Stack" for Flutter 3.47.2? Specifically:
    • Which AGP version is fully tested and stable with this release? (e.g., 8.7.2 or 8.10?)

    • Which Gradle version is recommended to avoid the "Unsupported Gradle Project" warning?

    • Should I avoid Android SDK 37 / API 36 for now to ensure plugin compatibility?

    Thank you for your assistance in resolving this critical toolchain issue.

    Final Confirmation: Reproducible on Clean "Hello World" Project

    I have confirmed that this issue is a core Flutter SDK regression. I created a completely new project (flutter create testproject) with NO external plugins and applied the AGP 9.1.0 / Gradle 9.3.1 toolchain.

    Result:

    The build fails with the exact same ClassCastException.

    Stack Trace Analysis:

    The verbose logs pinpoint the failure to:
    com.flutter.gradle.FlutterPlugin.addFlutterTasks(FlutterPlugin.kt:354)

    Technical Summary:

    The flutter-gradle-plugin is attempting to cast ApplicationExtensionImpl (the new AGP 9.1 DSL implementation) to AbstractAppExtension (a legacy internal AGP class). Since AGP 9.0+ has moved to a strict interface-based DSL, this legacy class no longer exists or is incompatible, causing the plugin to crash during the task-adding phase.

    This proves that Flutter 3.47.2 is currently broken for any project attempting to use the AGP 9.1.0 verified toolchain on Windows.

    I am attaching the full verbose logs from the clean project for your review.

    verbose_logs.txt

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 1, 2026
  5. added
    platform-androidAndroid applications specifically
    toolAffects the "flutter" command-line tool. See also t: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-androidOwned by Android platform team
    and removed
    in triagePresently being triaged by the triage team
    needs repro infoAutomated crash report whose cause isn't yet known
    on Sep 1, 2026
  6. mbcorona commented on Sep 1, 2026

    @mbcorona
    Member

    Hi @bahaa599599, thanks for the repro steps and for reproducing it again on a clean project with no third-party plugins.
    Routing to the Android team for further investigation.

  7. bahaa599599 commented on Sep 2, 2026

    @bahaa599599
    Author

    @mbcorona

    Let's be clear, I'm still a beginner in Flutter programming. This is my first real project. I was programming normally until I updated Flutter and Gradle, and some problems arose that I hadn't encountered before. I tried using AI models to help me solve the problem, but they failed, and the application wouldn't build in any way. That's why I'm posting the problem here. After some attempts today, I managed to run the application, but I encountered one problem with a library that refused to work: cronet_http 1.9.0. So, I temporarily used HTTP instead. I will attach the latest Android file settings.

    gradle.properties

    android.useAndroidX=true
    android.newDsl=false
    android.builtInKotlin=false
    android.defaults.buildfeatures.resvalues=true
    android.sdk.defaultTargetSdkToCompileSdkIfUnset=true
    

    settings.gradle.kts

        val flutterSdkPath = run {
            val properties = java.util.Properties()
            file("local.properties").inputStream().use { properties.load(it) }
            val flutterSdkPath = properties.getProperty("flutter.sdk")
            require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
            flutterSdkPath
        }
    
        includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
    
        repositories {
            google()
            mavenCentral()
            gradlePluginPortal()
        }
    }
    
    plugins {
        id("dev.flutter.flutter-plugin-loader") version "1.0.0"
        id("com.android.application") version "9.1.0" apply false
        id("org.jetbrains.kotlin.android") version "2.4.0" apply false
        id("com.google.gms.google-services") version "4.4.2" apply false
    }
    
    include(":app")
    

    gradle-wrapper.properties

    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip
    

    build.gradle.kts

        repositories {
            google()
            mavenCentral()
        }
    }
    
    val newBuildDir: Directory =
        rootProject.layout.buildDirectory
            .dir("../../build")
            .get()
    rootProject.layout.buildDirectory.value(newBuildDir)
    
    subprojects {
        val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
        project.layout.buildDirectory.value(newSubprojectBuildDir)
    
        afterEvaluate {
            if (project.hasProperty("android")) {
                val android = project.extensions.getByName("android")
                if (android is com.android.build.api.dsl.LibraryExtension) {
                    if (android.namespace == null) {
                        android.namespace = "com.generated.${project.name.replace(":", ".")}"
                    }
                    android.compileSdk = 36
                }
            }
        }
    }
    subprojects {
        project.evaluationDependsOn(":app")
    }
    
    tasks.register<Delete>("clean") {
        delete(rootProject.layout.buildDirectory)
    }
    

    build.gradle.kts

        id("com.android.application")
        // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
        id("dev.flutter.flutter-gradle-plugin")
    }
    
    android {
        namespace = "com.example.moon"
        compileSdk = 36
        ndkVersion = flutter.ndkVersion
    
        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_21
            targetCompatibility = JavaVersion.VERSION_21
        }
    
        defaultConfig {
            applicationId = "com.example.moon"
            minSdk = flutter.minSdkVersion
            targetSdk = 36
            versionCode = flutter.versionCode
            versionName = flutter.versionName
        }
    
        buildTypes {
            release {
                signingConfig = signingConfigs.getByName("debug")
            }
        }
    
        dependencies {}
    }
    
    flutter {
        source = "../.."
    }
    

    The libraries I used in the project.

      flutter:
        sdk: flutter
      flutter_localizations:
        sdk: flutter
      intl: ^0.20.3
      l10n_currencies: ^2.0.3
      flutter_bloc: ^9.1.1
      flutter_screenutil: ^5.9.3
      flutter_svg: ^2.3.0
      internet_connection_checker: ^3.0.1
      shared_preferences: ^2.5.5
      shared_preferences_android: ^2.4.28
      image_picker: ^1.2.3
      image_cropper: ^12.2.1
      pinput: ^6.0.2
      cupertino_icons: ^1.0.9
      firebase_core: ^4.14.0
      firebase_auth: ^6.6.1
      cloud_firestore: ^6.9.0
      firebase_storage: ^13.5.0
      firebase_app_check: ^0.4.7
      freezed_annotation: ^3.1.0
      json_annotation: ^4.12.0
      carousel_slider: ^5.1.2
      cached_network_image: ^4.0.0
      collection: ^1.19.1
      smooth_page_indicator: ^3.0.0
      skeletonizer: ^2.1.3
      infinite_scroll_pagination: ^5.1.1
      device_preview: ^3.0.0
      visibility_detector: ^0.4.0+2
      flutter_map_cache: ^2.1.0
      location_picker_flutter_map: ^4.1.0
      country_picker: ^2.0.28
      flutter_rating_bar: ^4.0.1
      typesense: ^0.6.0
      cloud_functions: ^6.4.0
      fluttertoast: ^10.0.0
      go_router: ^18.0.0
      flutter_cache_manager: ^3.4.2
      http: ^1.6.0
    
      path_provider: ^2.1.6
      http_cache_hive_store: ^5.1.1
      path: ^1.9.1
    
    dependency_overrides:
    #  cronet_http: ^1.9.0
    #  cupertino_http: ^3.0.2
    
    
    
    
    dev_dependencies:
      flutter_test:
        sdk: flutter
      build_runner: ^2.16.0
      freezed: ^4.0.0
      json_serializable: ^6.14.1
      geolocator_android: ^5.0.3
      flutter_lints: ^6.0.0
      very_good_analysis: ^10.3.0
    

    Regarding the cronet_http library: ^1.9.0, it caused the application to fail completely when it was in dependencies. If it was in dependency_overrides, the application would be built, but you would not be able to download images from firebase.

  8. gmackall commented on Sep 8, 2026

    @gmackall
    Member

    I don't see the stacktrace you indicate in your verbose logs.

    Also

    KOTLIN VERSION VALIDATION ERROR:
    Flutter fails to recognize the built-in Kotlin version, reporting: 'Your project's Kotlin version (2.2.10) is lower than Flutter's minimum supported version of 2.2.20', even when KGP 2.4.0 is defined.

    This makes me think what you're actually hitting is #192167

    Can you try passing --android-skip-build-dependency-validation to your build?

    Otherwise can you include a version of the verbose logs which includes the stacktrace you mention?

  9. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 8, 2026
  10. flutter-triage-bot commented on Sep 15, 2026

    @flutter-triage-bot

    This issue is missing a priority label. Please set a priority label when adding the triaged-android label.

  11. umerbashir-del commented on Sep 18, 2026

    @umerbashir-del

    I can reproduce a related Android build failure on Windows with a minimal Flutter app that has no native plugins.

    Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
    Cannot query the value of this provider because it has no value available.
    

    My tests:

    • Windows 11
    • Flutter stable 3.47.4 / Dart 3.13.3
    • Also tested Flutter 3.38.10 / Dart 3.10.9 in a separate toolchain
    • Android SDK platform 37.0 and build-tools 36.0.0
    • Microsoft OpenJDK 17 and Android Studio's bundled JBR
    • A newly created Flutter app with no native plugins
    • Cleared Gradle cache/daemons, used an isolated Gradle user home, and reinstalled the Android platform/build tools
    • Also tested AGP 8.11.1, Kotlin 2.2.20, and Gradle 8.14

    Every test fails during assembleDebug with the same provider error. Web builds work correctly.

    Is this likely related to the Flutter Gradle-plugin/AGP compatibility problem being tracked here, or should I open a separate focused issue with a minimal reproduction?

  12. added
    triaged-androidTriaged by Android platform team
    and removed
    triaged-androidTriaged by Android platform team
    on Sep 22, 2026
  13. jesswrd commented on Sep 22, 2026

    @jesswrd
    Contributor

    @umerbashir-del I think your case may be a different issue. Can you create a new issue and provide a minimal reproducible sample? Also, let's make sure you are using openJDK 17. Make sure OpenJDK 17 is downloaded and exists on your machine then run flutter config --jdk-dir="<path/to/java/binary>". Try buildling your flutter app again.

  14. umerbashir-del commented on Sep 24, 2026

    @umerbashir-del

    Update: I followed the requested OpenJDK 17 check and retested with a minimal Flutter project on Windows.

    • Flutter 3.47.4
    • Microsoft OpenJDK 17.0.20, configured with flutter config --jdk-dir
    • Android SDK command-line tools installed; licenses accepted
    • Android SDK platform 37 / build-tools 36.0.0
    • Gradle 8.14, AGP 8.11.1, Kotlin 2.2.20

    The initial build was blocked because NDK 28.2.13676358 was not installed. After installing that exact NDK version, flutter build apk -v completed successfully and produced the release APK.

    I can no longer reproduce the original provider error with this minimal setup, so I will not open a separate issue at this time.

  15. github-actions commented on Sep 29, 2026

    @github-actions

    Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now.

    If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones.

    Thanks for your contribution.

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

    found in release: 3.47Found to occur in 3.47has 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.waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions