Back to Blogs

Introducing our dexinfo Gradle plugin

Mobile App Development
Article
Technology, Information and Media
Post_20150120_AndroidDEX_Header

As applications are getting increasingly complex, more and more Android developers are running into the DEX 64K limit. We covered this topic–and how to work your way around it–in a previous post, so make sure you read it if you haven’t done so already.

Most developers don’t worry about this limit while working on their apps, and then end up spending a lot of time and effort to resolve it. We believe that prevention is better than finding a cure. Before you choose to bring a cool library into your code base, one of the things you should seriously consider is how many methods it adds to your application.

To date, we’ve had multiple ways of counting the methods in an application, like this one by Jake Wharton and this one by Mihai Parparita. However, we thought we can make things easier for developers by providing this functionality in the form of a Gradle plugin that you can simply integrate into your application. Today, we are happy to announce the plugin is publicly available!

How to use it

Add the dexinfo plugin in your app’s build.gradle

buildscript {repositories {jcenter()}dependencies {classpath 'com.mutualmobile.gradle.plugins:dexinfo:0.1.2'}}Apply the plugin after the ‘com.android.application’ or ‘com.android.library’ pluginsapply plugin: 'com.android.application'apply plugin: 'com.mutualmobile.gradle.plugins.dexinfo'Build your apk> ./gradlew -q assembleDebugRun the dexinfo task> ./gradlew -q dexinfoDebug$ ../gradlew dexinfoDebug:example:dexinfoDebugProcessing /Users/foo/git/example/build/intermediates/dex/devServer/debug/classes.dexRead in 38163 method IDs.: 182butterknife: 182ButterKnife: 48Action: 1Finder: 221: 32: 33: 3Finder[]: 1Injector: 2ImmutableList: 4InjectView: 1InjectViews: 1OnCheckedChanged: 1OnClick: 1...internal: 99Binding: 1ButterKnifeProcessor: 22CollectionBinding: 12Kind: 5Kind[]: 1DebouncingOnClickListener: 71: 2ListenerBinding: 5ListenerClass: 11NONE: 4NONE[]: 1ListenerMethod: 4Parameter: 5ViewBinding: 6ViewInjection: 8ViewInjector: 181: 1Overall method count: 182BUILD SUCCESSFUL

You can also specify various options like how far into package paths the count should be reported for, get the count for a specific package, get count only for referenced methods, etc. We’ve been using this internally for some time now and have already saved a lot of time in the process, we hope you’ll find it useful too.

Check it out on GitHub for more information, and remember that pull requests are always welcome!

Mutual Mobile

Mutual Mobile Resource Team.

More by this author