Count the number of methods in the APK and the number of APK Methods

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.