Home » Android » Which method count represents total methods in my APK?

Which method count represents total methods in my APK?

Posted by: admin November 1, 2017 Leave a comment

Questions:

After building my APK, I get the following message when I open it in Android Studio:

This dex file defines 4837 classes with 29856 methods, and references 42784 methods.

Does anyone know which value/number needs to be taken into consideration when trying to avoid reaching the 64K method limit? The first (29856) or the second (42784)?

Answers:

Which method count represents total methods in my APK?

The first number. Note that this includes your code plus any libraries that you are including (e.g., via dependencies in Gradle, including transitive dependencies).

Does anyone know which value/number needs to be taken into consideration when trying to avoid reaching the 64K method limit?

The limit that I suspect that you are thinking of is the 64K DEX method reference limit, which is represented by the second number.

For a regular (non-multidex) app, the difference between the second number (method reference count) and the first number (method count) is the number of methods in the Android SDK that you are referencing.