Repository navigation
[BUG] Fatal Build Incompatibility: Flutter 3.47.2 + AGP 9.1.0 + Gradle 9.3.1 + Android SDK 37 (Windows) #192111
Description
Steps to reproduce
- Use Flutter 3.47.2 (Stable) on Windows 11.
- Update 'gradle-wrapper.properties' to use Gradle 9.3.1.
- Update 'settings.gradle.kts' to use Android Gradle Plugin (AGP) 9.1.0.
- Set 'compileSdk' and 'targetSdk' to 36 in 'android/app/build.gradle.kts'.
- Use Kotlin 2.4.0 (KGP) and Android SDK 37 command-line tools.
- Attempt to enable modern AGP features in 'gradle.properties':
android.newDsl=true
android.builtInKotlin=true - 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:
-
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'. -
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+. -
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. -
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. -
DSL NAME COLLISION (Kotlin DSL):
'signingConfig = signingConfigs.debug' fails with 'Assignment type mismatch' because 'debug' is shadowed by 'NamedDomainObjectProvider'. Requires 'signingConfigs.getByName("debug")'. -
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. -
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.
- 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.
- Manual Path Injection: Setting 'android.home' and 'android.sdk.path' via System properties in settings.gradle.kts failed to bypass the service initialization error.
- 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.
- 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
mbcorona commentedon Sep 1, 2026
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.
bahaa599599 commentedon Sep 1, 2026
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:
Created a new project via flutter create testproject.
Updated gradle-wrapper.properties to Gradle 9.3.1.
Updated settings.gradle.kts to AGP 9.1.0.
Enabled Modern Mode in gradle.properties: android.newDsl=true android.builtInKotlin=true
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-pluginis attempting to castApplicationExtensionImpl(the new AGP 9.1 DSL implementation) toAbstractAppExtension(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
mbcorona commentedon Sep 1, 2026
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.
bahaa599599 commentedon Sep 2, 2026
@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
settings.gradle.kts
gradle-wrapper.properties
build.gradle.kts
build.gradle.kts
The libraries I used in the project.
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.
gmackall commentedon Sep 8, 2026
I don't see the stacktrace you indicate in your verbose logs.
Also
This makes me think what you're actually hitting is #192167
Can you try passing
--android-skip-build-dependency-validationto your build?Otherwise can you include a version of the verbose logs which includes the stacktrace you mention?
chore(android): raise AGP to 8.13.2 for share_plus/package_info_plus
flutter-triage-bot commentedon Sep 15, 2026
This issue is missing a priority label. Please set a priority label when adding the
triaged-androidlabel.umerbashir-del commentedon Sep 18, 2026
I can reproduce a related Android build failure on Windows with a minimal Flutter app that has no native plugins.
My tests:
Every test fails during
assembleDebugwith 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?
jesswrd commentedon Sep 22, 2026
@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.umerbashir-del commentedon Sep 24, 2026
Update: I followed the requested OpenJDK 17 check and retested with a minimal Flutter project on Windows.
flutter config --jdk-dirThe initial build was blocked because NDK
28.2.13676358was not installed. After installing that exact NDK version,flutter build apk -vcompleted 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.
github-actions commentedon Sep 29, 2026
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.
github-actions commentedon Oct 13, 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.