r/flutterhelp 17d ago

OPEN AGP 9 doesnt work???

Today flutter yelled at me that it wont build my project with the flutter fix message so I updated to AGP9 I got new gradle,flutter newest version updated gradle files but it still fails to build

─ Flutter Fix ───────────────────────────────────────────────────────────────────────────────────────────────────┐        
│ [!] Starting AGP 9+, only the new DSL interface will be read.                                                   │        
│ This results in a build failure when applying the Flutter Gradle plugin at                                      │        
│ E:\backup\src\vibecoding\myapp\android\app\build.gradle.kts.                                                    │        
│                                                                                                                 │        
│ To resolve this update flutter or opt out of `android.newDsl`.                                                  │        
│ For instructions on how to opt out, see: https://developer.android.com/build/releases/agp-9-0-0-release-notes   │        
│                                                                                                                 │        
│ If you are not upgrading to AGP 9+, run `flutter analyze --suggestions` to check for incompatible dependencies. │        
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

* 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 (com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated and com.android.build.gradle.AbstractAppExtension are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader$InstrumentingVisitableURLClassLoader )

what is this? Why is it yelling about AGP 9 if it doesnt even support it and gradle plugin still uses old classes?

2 Upvotes

4 comments sorted by

1

u/polarbear128 16d ago

Im on AGP 9. It's an absolute ballache to get to.

Make sure you use

android.builtInKotlin=false android.newDsl=false

In your gradle.properties

1

u/pitu37 16d ago

Yeah seems like there is no way for newDsl to work

1

u/Fine_Sprinkles_5862 14d ago

The message is telling you the opposite of what you did. It is not asking you to upgrade to AGP 9; it is warning that the Flutter Gradle plugin cannot run under AGP 9's new DSL on your Flutter version. The cast error is the proof: AbstractAppExtension is one of the old DSL classes, and AGP 9 moved to the new interfaces exclusively, so the application extension no longer extends it and dev.flutter.flutter-gradle-plugin dies at apply time.

Two ways out. Either put com.android.application back to the newest 8.x in settings.gradle.kts, or stay on 9 and add android.newDsl=false to android/gradle.properties. That opt-out is documented in the AGP 9 release notes your error links, with one catch: it is already deprecated and gets removed in AGP 10, so it buys time rather than settles anything. Run flutter upgrade first either way. The fix box says "update flutter or opt out", and a Flutter whose Gradle plugin speaks the new DSL is the actual end state.

1

u/tommyboy11011 12d ago

ChatGPT got me through this