Open SherpaMiguel opened 4 months ago
Any workaround for now?
@jonasborggren yep, add this into your android/build.gradle
subprojects {
afterEvaluate {
if (project.plugins.hasPlugin("com.android.application")
|| project.plugins.hasPlugin("com.android.library")) {
// TODO FIX
// https://github.com/matanshukry/flutter_google_places_sdk/issues/71
if (project.name == "flutter_google_places_sdk_android") {
project.android.compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
}
}
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
@SherpaMiguel @jonasborggren can you explain the steps you're taking to get this error, or even create a reproducible example?
I'm using java 19.0.2, gradle 8.1.1, and running flutter build appbundle
on the example project works fine.
@matanshukry in settings.gradle, update "com.android.application" (Gradle) to 8.2.2 and "org.jetbrains.kotlin.android" to 1.9.22
This is my plugin configuration in settings.gradle:
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.2.2" apply false // VERSIÓN GRADLE
id "org.jetbrains.kotlin.android" version "1.9.22" apply false // VERSIÓN KOTLIN
// START: FlutterFire Configuration
id "com.google.gms.google-services" version "4.4.0" apply false
id "com.google.firebase.crashlytics" version "2.9.9" apply false
id "com.google.firebase.firebase-perf" version "1.4.2" apply false
// END: FlutterFire Configuration
}
Also followed this migration guide: https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply
Note that this problem is ocurring in some other Flutter plugins: https://github.com/fluttercandies/flutter_image_compress/issues/270
@SherpaMiguel When inserting your afterEvaluate
script into the bottom of android/build.gradle
, I get an error on build: Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.
EDIT: Figured it out
The bottom of the build.gradle file in a default Flutter setup will end up looking like this:
rootProject.buildDir = '../build'
subprojects {
afterEvaluate {
if (project.plugins.hasPlugin("com.android.application")
|| project.plugins.hasPlugin("com.android.library")) {
if (project.name == "flutter_google_places_sdk_android") {
project.android.compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}
}
}
}
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
@SherpaMiguel When inserting your
afterEvaluate
script into the bottom ofandroid/build.gradle
, I get an error on build:Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.
The afterEvaluate script should be inside "subprojects", in the root of android/build.gradle.
When using Gradle 8 (requires JDK 17):
Execution failed for task ':flutter_google_places_sdk_android:compileDebugKotlin'. 'compileDebugJavaWithJavac' task (current target is 1.8) and 'compileDebugKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version. Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain