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

前端 未结 7 904
囚心锁ツ
囚心锁ツ 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:31

    I had a different compilation argument to set. The following works for me.

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-XDignore.symbol.file"
            options.bootClasspath = "$System.env.JAVA_HOME/jre/lib/rt.jar"
        }
    }
    

    You have to set the boot classpath for JDK 1.8 and above for things like Unsafe and sun.swing.* classes. Fix the source code especially for the latter, because Jigsaw Java 9, the up and coming modularity implementation for the JRE, will finally make these methods inaccessible(!). Consider yourself warned.

提交回复
热议问题