Making Your Android App Better With Static Analysis

Android Code InspectionAny way to get free testing and bugfixing for your Android app is a good thing.  The less bugs you let slip through the door, the better for your ratings and the less time you have to spend tracking bugs down.

In my corporate life, I used static and dynamic code analysis tools. They’re great for finding bugs before they even get to testing, let alone the users. In fact, you can find some very rare bugs using these analysis tools.

However, I’ve been flying without a net with my Android development. After I released a major bug last week (if the user visited the preferences, the app would force close even after restarting!), I decided that this task was long overdue.  Getting a negative review from a frustrated user was also motivating.

Here are the three static analysis tools I looked at (the first two are free):

FindBugs – I installed FindBugs and am very pleased with it. The setup was quick, and the workflow is good for me. I already found a few minor things to clean up.

After you set up FindBugs, check out these instructions to suppress trivial warnings.

PMDWhile PMD is a little harder to use, it found a whole lot of other things, including performance-related items. It does have a lot of noise, however, so ultimately it should be configured to hide trivial warnings. The statistics feature makes me think it would be very useful in a larger development environment.

PMD also needs some customization for Android.

Klocwork Solo – I intend to try out Klocwork Solo, but will wait until I’m about to release my next app. The demo only lasts 30 days, and I’m not sure I’ll want to spend $599 per year for it. Perhaps once I have more apps to be managing.

UPDATE – I downloaded Klocwork Solo and ran all of my code through it.  Frankly, I’m not impressed.  I know that I already polished my code with the other two tools, but honestly I expected more from an expensive product than just a few false positives.

Moreover, the Solo product is old, and won’t be updated.  Klocwork now puts their effort into their $25k team product, which manages workflow and a lot of other things besides static analysis.  Not the right product for me at all.

Where to start

I recommend starting with FindBugs, since it is simple to set up and use. I also use PMD now, and suggest you look at it when you have time.

UPDATECodePro AnalytiX is also a useful product (and free).  I have been using it with good results as well.

A final word of caution – don’t blindly implement suggestions from static analysis tools.  Sometimes the suggestions are wrong for your situation.  It’s just a hint!

I hope these tools help you keep your apps as bug-free as possible!

Sign up for the mailing list or subscribe to the feed for this blog to get more Android tips.

Posted in Android permalink

About ProjectJourneyman

I am a software engineer that escaped the cubicle world at a large company to go solo with Android app development. My attention to detail and quality applies both to my apps and to my research on how to make money with Android. Now that I have the freedom to work on my own projects, I am documenting my efforts in the hopes that it will help other current or aspiring independent Android developers get the income they desire.

Comments

Making Your Android App Better With Static Analysis — 1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>