Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
Expand Down Expand Up @@ -82,14 +78,20 @@ android {
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8
}
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile).configureEach {
Comment on lines -85 to +87
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason to change org.jetbrains.kotlin.gradle.tasks.KotlinCompile to org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile?

Copy link
Member Author

@rajveermalviya rajveermalviya Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KotlinCompile (not sure why it's documentation is in org.jetbrains.kotlin.gradle.dsl package and not org.jetbrains.kotlin.gradle.tasks) is deprecated in favor of one-of the KotlinCompilationTask, and KotlinJvmCompile is a subclass of KotlinCompilationTask.

Also the migration guide (expand the "Migrate from kotlinOptions {} to compilerOptions {}" section) has a handy migration example for this "compilation unit level" configuration.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I think you mean KotlinCompile is the deprecated thing?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes!

// Compile Kotlin with `-Werror`... but only in release builds, so that it
// doesn't get in the way of quick local experiments for debugging.
//
// The string-searching makes this a bit of a mess, but it works.
// Better would be if we can add this to android.buildTypes.release above;
// but on a first attempt that didn't work (it affected debug builds too).
kotlinOptions.allWarningsAsErrors = name.contains("Release")
compilerOptions.allWarningsAsErrors = name.contains("Release")
}

flutter {
Expand Down