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/PlaylistFragment.java uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
How do I recompile with this option? Do I have to edit something in my build.xml?
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
Even simpler and without the need to copy a complete javac target: put the following line in ant.properties file :
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! :)
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:
or
If you only want to add one option (you would normally add more), inside the task
JavaCompile
you just need to add: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.
Yes, per the statement below in the build.xml file, if you want to ...
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:
Likewise, you can add other compiler options, such as for unchecked operations:
It looks like you should just be able to specify the option in either
build.properties
orant.properties
in the root of your project folder. I tried this and it didn't seem to work. I wanted to avoid editing mybuild.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 wholecompile
target I added:just before the
import
line at the bottom of the file.