Run Android Lint from command line

Run Android Lint from command line

Not many of us use android Lint tool to scan the projects for possible performance or best practices tips. Eclipse has the Lint tool included into adt plugin so Eclipse users can take advantages of this. Ok but what about developers that use intellij IDEA or other IDE for android projects? The answer is simple, you just need the android sdk environment to be installed on your computer. The steps to run a scan on your android project and see the report in a html page are:

  • open command line (cmd in windows) 
  •  navigate to “tools” directory located in android installation directory 
  • here you just have to type : 

command –   lint –html < html_output_path > < your_android_project_path > 
     eg:               lint –html C:report.html C:yourAndroidProject 

  • go to html_path and open the html test report 🙂

Note: that the html_output_path is automatically created by Lint however you can type an already existing html for output and Lint will override the existing html with the new report.

For those that get C:report.html < Access is denied > it means that the html report file could not be saved on that path.. you could try to change the path to other partition or path other than C: root.  Or you could just create a directory in C: using Windows Explorer, call it “reports” and then you could try again the command like this : lint –html C:reportsreport.html C:yourAndroidProject .

One thing I found. In the results.html I got UnusedResources warning, please make sure that those resources are really unused because many of those resources were used in my project…

You could find more about Lint tool here.

UPDATE: The new Intellij IDEA (version 11.1) has integrated Lint tool. If you want to run the Lint analysis in intellij, just click on the Analyze menu and then Inspect code.
Btw, it seems that has shortcuts to ddms and nine patch too!