Count the number of methods in the APK and the number of APK Methods
In Android development, there is a limit on the number of APK methods, which cannot exceed 65536. If this number is exceeded, the following exception occurs:
Conversion to Dalvikformat failed: Unable toexecute dex: method ID not in [0, 0 xffff]: 65536
The main reason for the above problem is that in Android, the short type data is used for storing the method id in the Dex file, so the dex method cannot exceed 65 KB.
With the above restrictions, how can we know the number of methods used to generate the APK? And how to solve the total number of methods in the APK exceeds 65536 and generate the package.
We can use dex-method-counts (https://github.com/mihaip/dex-method-counts) to count the total number of packages, the method is simple, just execute the following statement:
Java-jar path \ dex-method-counts.jar path \ App.apk
To save the trouble of re-compiling jar packages
Knowing the number of methods in the Statistical Package, what should I do if the limit is exceeded?
The first thought is to remove unused functions in the code, Remove unused jar packages, and change the class members from private to public to reduce the set/get function. However, these are all methods for de-tagging. Is there any better solution?
Plug-ins in a similar way or use the subcontracting mechanism.
For details, refer to the solution provided by Meituan:
Http://tech.meituan.com/mt-android-auto-split-dex.html
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.