How to recompile with -Xlint:unchecked in Ant buil

2019-03-22 12:40发布

When I run the "compile" target of my Ant "build.xml" file, then I get the following message:

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

My compile target is the following:

  <target name="compile">
    <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true" debuglevel="lines,source" includeantruntime="false">
      <classpath refid="class.path" />
    </javac>
    <javac srcdir="${test.dir}" destdir="${classes.dir}" debug="true" debuglevel="lines,source" includeantruntime="false">
      <classpath refid="class.path" />
    </javac>
  </target>

What do I have to change in my build.xml file so that -Xlint:unchecked is done there?

2条回答
男人必须洒脱
2楼-- · 2019-03-22 13:01

I have tested it, It works. try to add following element in <javac></javac> section:

<compilerarg value="-Xlint:unchecked"/>
查看更多
The star\"
3楼-- · 2019-03-22 13:04

In AndroidStudio, do this:

allprojects {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xlint:deprecation"
    }
}
查看更多
登录 后发表回答