Failure on build with Gradle on command line with an android studio project : Xlint error

久未见 提交于 2019-11-29 19:50:18
shakalaca

It's a nice warning, not an error. To see the complete lint report you can add these lines to build.gradle:

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

If you really want to get rid of those warnings:

  1. Don't use deprecated API
  2. Use @SuppressWarnings("deprecation")

This is fairly obvious from @shakalaca's answer, but if you have code old enough to get the deprecation warning, you may also have code old enough to use unchecked operations, e.g. a List without the parameterized type as in List<String>. This will get you an additional warning:

Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

You can just expand the compiler args block to include that as well:

allprojects {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!