Add compiler flags to the standard android build.xml
I want to add -Xlint:deprecated to the java compiler while building android app.
I've seen the compilerarg tag 开发者_运维百科inside javac tags, but the generated build.xml for the standard project doesn't have such a tag. Any hint?the full build script is located YOUR_SDK_FOLDER/platforms/SDKVERSION/templates/android_rules.xml
you modify your build.xml with copy of this file and customize it. Not sure if it'll get where you want - but it's a start
<!-- Execute the Android Setup task that will setup some properties specific to the target,
and import the rules files.
To customize the rules, copy/paste them below the task, and disable import by setting
the import attribute to false:
<setup import="false" />
This will ensure that the properties are setup correctly but that your customized
targets are used.
-->
There is a java.compilerargs
property in the default $SDKDIR/tools/ant/build.xml
file that you can override in the ant.properties
in your project, such as:
java.compilerargs=-Xlint:unchecked -Xlint:deprecation
Add this to <project>/app/build.gradle
(not the global build.gradle):
preBuild {
doFirst {
JavaCompile jc = android.applicationVariants.find { it.name == 'debug' }.javaCompile
jc.options.compilerArgs = ["-Xlint:deprecation"]
}
}
精彩评论