Hi! I’ll share a few tips with you on how to find out the number of methods that your Android app has. I’m gonna show you a few tools such as APK file methods counter, and an Android plugin that will show you the number of methods each imported class or dependency has. These will help you figure out if you’re nearing the 64K methods limit, and determine which classes/dependencies must be causing it.
First off, try this online drag-and-drop tool that will show you the total method count as well as breakdown based on the APK file you’ll use: APK Method Count
Now, let’s install the plugin. After installation, you should be able to see method counts on your
Install plugin to check for unused dependencies: Jonnyzzz Dependencies. I used version 1.0.10. To do this, in [Windows] go to File -> Plugins, or in [Mac] go to Android Studio -> Preferences. Press “Browse Repositories” then find and install Jonnyzzz Dependencies. Restart Android Studio.
To use, from the menu, select Tools -> Unused Module Dependencies -> Analyse All Modules
You’ll be prompted for an option to remove all unused dependencies. I could not do that because I had a team mate who might use some of those in the list, so I manually deleted libraries that I’m sure we no longer need.
Sync Gradle, Clean, or even Rebuild… and run your app again.
I must admit that this DEX file error is a nightmare to me. xD I used to only code my Android app in a Windows 7 computer, which was very slow. Then some office friends decided to lend me a higher-specs Mac Mini that nobody’s using. It’s helping a lot, but the app I’m working on in Windows is getting 64K methods limit in Mac. I had the exact same copy of my Android Studio project in both Windows and Mac computers, but only the one in Mac was getting 64K methods limit error. 😆
Now I’m thinking of the small differences in my Windows’ and Mac’s config for Android Studio…
Could it be because ‘com.google.gms:google-services:2.0.0-alpha9’ and Android Studio v.2.1 in Mac, while my Windows 7 had ‘com.google.gms:google-services:2.0.0-alpha6’ and Android Studio v.1.4?
My Android Studio v.1.4 in Windows using Alpha 6 (more methods) but the app runs without problem, while Android Studio 2.1 in Mac using Alpha 9 (less methods) triggers the 64K methods limit. 😆
I don’t want to keep thinking about this right now because I have pending tasks to do. 😆 But it’s nice to know roughly what we can do next time I get this dreaded 64K methods limit error.