Skip to content

Commit a618e33

Browse files
committed
android build: Treat Kotlin warnings as errors, in release builds
In particular this applies to the new `tools/check android`. A StackOverflow question that had a couple of helpful answers: https://stackoverflow.com/questions/34562200/how-do-i-make-the-kotlin-compiler-treat-warnings-as-errors
1 parent cdc72c6 commit a618e33

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

android/app/build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ android {
7474
}
7575
}
7676

77+
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
78+
// Compile Kotlin with `-Werror`... but only in release builds, so that it
79+
// doesn't get in the way of quick local experiments for debugging.
80+
//
81+
// The string-searching makes this a bit of a mess, but it works.
82+
// Better would be if we can add this to android.buildTypes.release above;
83+
// but on a first attempt that didn't work (it affected debug builds too).
84+
kotlinOptions.allWarningsAsErrors = name.contains("Release")
85+
}
86+
7787
flutter {
7888
source '../..'
7989
}

0 commit comments

Comments
 (0)