A note that specifies compile options such as -Xlint: deprecation and -Xlint: unchecked when building an Android app with Gradle. Note that the specification method differs between Java and Kotlin.
build.gradle
allprojects {
    gradle.projectsEvaluated {
        
        //Java compile time
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
        //Kotlin at compile time
        tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
            kotlinOptions {
                freeCompilerArgs = [
                        "-Xjavac-arguments='-Xlint:unchecked -Xlint:deprecation'"
                ]
            }
        }
    }
}
Recommended Posts