This code has been deprecated and should be migrated using the official documentation.
(I.e. https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply )
What worked for me was adding the below code in the android/settings.gradle file get the agpVersion and kotlinVersion from the <app-src/android/build.gradle> file
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "{agpVersion}" apply false
id "org.jetbrains.kotlin.android" version "{kotlinVersion}" apply false}
Remove the whole buildscript block from <app-src/android/build.gradle>
Remove the following code from <app-src/android/app/build.gradle>:
-def flutterRoot = localProperties.getProperty('flutter.sdk')
-if (flutterRoot == null) {
- throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
-}
Dependencies in <app-src>/android/build.gradle buildscripts need to be moved to the plugin block of setting.gradle
Remove lines like:
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
And add them to <app-src>/android/app/build.gradle like:
plugins {
id "com.android.application"
id "dev.flutter.flutter-gradle-plugin"
id "org.jetbrains.kotlin.android"
+ id "com.google.gms.google-services"
+ id "com.google.firebase.crashlytics"
}