So I almost always get some message like this when I\'m compiling my android app:
[javac] Note: /home/kurtis/sandbox/udj/androidApp/src/org/klnusbaum/udj/Playlis
If you want to have a good CI + CD pipeline and you care about your code quality, a good option to show more information about lint complainings is by adding this to your top/root gradle.build:
subprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs += [
'-Xlint:unchecked', // Shows information about unchecked or unsafe operations.
'-Xlint:deprecation', // Shows information about deprecated members.
]
}
}
}
or
subprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
If you only want to add one option (you would normally add more), inside the task JavaCompile
you just need to add:
options.compilerArgs << "-Xlint:unchecked"
It's 2018 and you can rely on Gradle to set this up. I only added two compiler argument options but there are much more. You can find more information here and here.
These properties can also be defined on the Ant command line, avoiding edits:
ant "-Djava.compilerargs=-Xlint:unchecked -Xlint:deprecation" debug
To enable all Lint warnings:
ant -Djava.compilerargs=-Xlint debug
Yes, per the statement below in the build.xml file, if you want to ...
- Customize only one target: - copy/paste the target into this file, *before* the <setup/> task. - customize it to your needs.
That means:
Go to the $ANDROID_SDK_ROOT/tools/ant/main_rules.xml file and copy the "compile" target.
Paste it into your build.xml file before the <setup/> task.
Then add the following element to the task:
<compilerarg value="-Xlint:deprecation"/>
Likewise, you can add other compiler options, such as for unchecked operations:
<compilerarg value="-Xlint:unchecked"/>
It looks like you should just be able to specify the option in either build.properties
or ant.properties
in the root of your project folder. I tried this and it didn't seem to work.
I wanted to avoid editing my build.xml
file as this adds complication later if you need to update your project. However, I was unable to find a way around it. However, rather than copying the whole compile
target I added:
<property name="java.compilerargs" value="-Xlint:unchecked" />
just before the import
line at the bottom of the file.
Even simpler and without the need to copy a complete javac target: put the following line in ant.properties file :
java.compilerargs=-Xlint:unchecked
This way, it just overrides java.compilerargs from Android SDK default build configuration. (You can check for yourself that it is empty by default, btw). No mess with SDK update that could change the default javac target without your project being notified.
Just a more granular way to do! :)