Closed LazreqYa closed 2 months ago
I got the same issue early this week on upgrading my app.
Found the solution by managing the upgrade of the Gradle and force the plugins to use the 17 version
Try:
Upgrade to gradle 8
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
Update the android application id "com.android.application" version '8.1.4' apply false
In your android build.gradle
to adapt subprojects:
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
afterEvaluate {
// check if android block is available
if (it.hasProperty('android')) {
if (it.android.namespace == null) {
def manifest = new XmlSlurper().parse(file(it.android.sourceSets.main.manifest.srcFile))
def packageName = manifest.@package.text()
println("Setting ${packageName} as android namespace")
android.namespace = packageName
}
def javaVersion = JavaVersion.VERSION_17
android {
def androidApiVersion = 34
compileSdkVersion androidApiVersion
defaultConfig {
targetSdkVersion androidApiVersion
}
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = javaVersion.toString()
}
}
println("Setting java version to ${javaVersion.toString()} which is $javaVersion")
println("Setting compileSdkVersion and targetSdkVersion to $androidApiVersion")
}
}
}
}
@stact thanks for the answer i just try your solution but the new XmlSlurper() is not reconize, even if i add the
import groovy.util.XmlSlurper
.
i finally just downgrade the google_api_headers and stop using the flutter_google_place.
Steps to Reproduce
Switch to this version
`------------------------------------------------------------ Gradle 8.9
Build time: 2024-07-11 14:37:41 UTC Revision: d536ef36a19186ccc596d8817123e5445f30fef8
Kotlin: 1.9.23 Groovy: 3.0.21 Ant: Apache Ant(TM) version 1.10.13 compiled on January 4 2023 Launcher JVM: 22.0.1 (Oracle Corporation 22.0.1+8-16) Daemon JVM: /Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home (no JDK specified, using current Java home) OS: Mac OS X 14.6.1 aarch64`
using Android Studio Gradle JDK 17
Expected behaviour
Want to run my android app with
flutter run
after a long time. The package works perfectly on ios but on android i can't compile.Actual behaviour
Actually every package are compiling but the google_api_header because of this :
Flutter doctor output
Additional Context
This package is used by the package flutter_google_place.