Skip to content

Commit 29e9482

Browse files
android build: Migrate to kotlin.compilerOptions from kotlinOptions
See: https://kotlinlang.org/docs/gradle-compiler-options.html#migrate-from-kotlinoptions-to-compileroptions Fixes: #1804
1 parent cf83c9e commit 29e9482

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

android/app/build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ android {
2929
targetCompatibility JavaVersion.VERSION_1_8
3030
}
3131

32-
kotlinOptions {
33-
jvmTarget = '1.8'
34-
}
35-
3632
sourceSets {
3733
main.java.srcDirs += 'src/main/kotlin'
3834
}
@@ -82,14 +78,20 @@ android {
8278
}
8379
}
8480

85-
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
81+
kotlin {
82+
compilerOptions {
83+
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
84+
}
85+
}
86+
87+
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile).configureEach {
8688
// Compile Kotlin with `-Werror`... but only in release builds, so that it
8789
// doesn't get in the way of quick local experiments for debugging.
8890
//
8991
// The string-searching makes this a bit of a mess, but it works.
9092
// Better would be if we can add this to android.buildTypes.release above;
9193
// but on a first attempt that didn't work (it affected debug builds too).
92-
kotlinOptions.allWarningsAsErrors = name.contains("Release")
94+
compilerOptions.allWarningsAsErrors = name.contains("Release")
9395
}
9496

9597
flutter {

0 commit comments

Comments
 (0)