I’m currently building my android project from the project folder with ant like the following:
MyProject/
build.xml
The ant command that I use to build is:
$ MyProject/ant install
In my java code, I have some unused imports and variables, for instance:
import java.io.IOException;
String doNothing = "Do Nothing";
I’m not making used of the above in my code. Is there way to detect those from the command line with ant? If not, do I have to use a third party tool?
In Python, I use pyflakes to cleanup my code. I’m looking for the equivalent in Java at the command line.
You can use PMD to do this and much more. It includes checks for both unused local variables and unused imports. It can be integrated with ant and you can configure it to fail the build if any errors are detected. If you are using the standard build structure that is created via the
androidcommand line tool you can tie the PMD target into the-pre-compilestage.