How to add -Xlint:unchecked to my Android Gradle based project?

前端 未结 7 909
囚心锁ツ
囚心锁ツ 2020-11-29 16:05

I tried to add the following to the root build.gradle file:

subprojects {
    gradle.projectsEvaluated {
        tasks.withType(Compile) {
              


        
7条回答
  •  广开言路
    2020-11-29 16:09

    For everyone using gradle.kts use the following to match up with the simple build.gradle file

    build.gradle.kts

    afterEvaluate {
            tasks.withType(JavaCompile::class) {
                options.compilerArgs.add("-Xlint:unchecked")
                options.compilerArgs.add("-Xlint:deprecation")
            }
        }
    

    build.gradle

     gradle.projectsEvaluated {
            tasks.withType(JavaCompile) {
                options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
            }
        }
    

提交回复
热议问题