Android APK size + dexcount charts on Jenkins

Marc Reichelt
2 min readMay 25, 2016

--

We at flinc put quite some effort in continuous integration. To improve your APK filesize and the number of method/field references in dex bytecode you first have to measure it. When I asked on Twitter I was pointed to the dexcount-gradle-plugin. It’s easy to use:

top-level build.gradle
app/build.gradle

Now, if you compile your project, the plugin will output the number of dex method & field references after every build:

output of ./gradlew app:assembleDebug

That’s already pretty helpful! :-)
If you don’t use Jenkins you can stop reading now.

Now, let’s hook up the plot in Jenkins. Install the Plot Plugin for Jenkins and configure it for your build:

Note you will have to adapt the path to the CSV file, which will be different for your project and has a different filename for debug/release. If everything works, you should be rewarded by a nice chart by the Plot Plugin, which is accessible if you click on Plots in your job (note that you should run the job 1–2 times first). Well, what do we have here?

Ok, now let’s track the APK size, too! Add a small shell script as the last build step of your Jenkins build:

And add the new plot via the ‘Add Plot’ Button (not the ‘Add’ button, which would add it to the same chart). Notice I use the same group ‘APK info’ here:

Let’s have a look at our final result:

Awesome!

Bonus tip: to easily troubleshoot creating plots, simply create a new free-style Jenkins job, copy over your desired .csv files to its workspace and start testing. You’ll get results in minutes.

I hope this will help you to easily track all the nice benefits you will get by putting your APK on a diet, enabling ProGuard, compressing images or using vector images altogether. Happy hacking!

--

--

Marc Reichelt

Developer. Loves Linux, Android & open source. Making the world better, one step at a time!