I recently upgrade my Flutter app from compileSdkVersion & targetSdkVersion 32 to 33 then to 34, along with upgrading AGP to 7.4, migrating the Flutter’s Gradle plugins and updating all other dependencies in androidappbuild.gradle to latest version. I tried to run the app but getting the following errors:
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mapDebugSourceSetPaths'.
> Querying the mapped value of map(flatmap(provider(task 'processDebugGoogleServices', class com.google.gms.googleservices.GoogleServicesTask))) before task ':app:processDebugGoogleServices' has completed is not supported
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 11s
Error: Gradle task assembleDebug failed with exit code 1
androidsettings.gradle:
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return 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 "7.4.0" apply false
id "org.jetbrains.kotlin.android" version "2.0.0-Beta4" apply false
id "com.google.gms.google-services" version "4.4.1" apply false
}
include ":app"
androidappbuild.gradle:
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"
}
ext.kotlin_version = '2.0.0-Beta4' // Or your desired Kotlin version
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
applicationId "com.raaiq.appname"
minSdkVersion 21
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation 'com.google.gms:google-services:4.4.1'
implementation 'com.google.firebase:firebase-core:21.1.1'
}
androidbuild.gradle:
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
In androidgradlewrappergradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle-7.5-all.zip
I have tried to downgrade com.google.gms.google-services
to lower version such as 4.3.15 but it doesn’t work. Please advise.
2
Answers
I realized that the problem occurs whenever I use
"com.android.application" version "7.4.0"
so I've downgraded it to7.3.0
and issue is resolved:In
androidsettings.gradle
:I have also made the following changes:
androidappbuild.gradle
: changeorg.jetbrains.kotlin:kotlin-stdlib-jdk7
toorg.jetbrains.kotlin:kotlin-stdlib
:androidgradlewrappergradle-wrapper.properties
::This seems to be good for now as I can't upgrade to AGP8+ yet because for some weird reason the AGP Upgrade Assistant in my Android Studio Iguana is missing/not showing up.
in the file
androidappbuild.gradle
change thisimplementation 'com.google.firebase:firebase-core:21.1.1'
to thisimplementation platform('com.google.firebase:firebase-bom:32.7.4')
androidappbuild.gradle:
androidbuild.gradle:
Compare the files in the
androidappbuild.gradle
file you have a lineext.kotlin_version = '2.0.0-Beta4'
that should not be there, take a look at my androidbuild.gradle file and compare