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!
Add the dexinfo plugin in your app’s build.gradle
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!