Android Fix 65536 limit

Source: Internet
Author: User

In Android development, we may import third-party jar packages, as Android projects grow, imported third-party jar packages will be more, this time, it is likely to encounter the problem of Project compilation packaging failure, is the Android 65k method limit. The error log is as follows

Error:execution failed for task ': Ttt:transformclasseswithdexfordebug '. Com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException: Java.util.concurrent.ExecutionException:com.android.dex.DexIndexOverflowException:method ID not in [0, 0xFFFF]: 65536

What is a 65k problem? In fact, it is very simple, Android has a limit, each App can only have a maximum of 65,536 functions.

The solution is the Multidex support library, because Android's IDE is basically Android studio, so here's just a workaround on as. First import this library Multidex support library. Then set the Build.gradle in the module

Android {   ...   Defaultconfig {     ...     multidexenabled True   }}

Then let your application class inherit from the Multidexapplication class, for example:

public class MyApplication extends Multidexapplication {   ...}

If it is not convenient to modify the inheritance (for example, has inherited the other encapsulated application) so long a little more complicated, overloaded Attachbasecontext, the code is as follows:

@Overrideprotected void Attachbasecontext (context base) {   Super.attachbasecontext (context);   Multidex.install (this);}

Then in the Androidmainfest file, modify the application to MyApplication, and then compile the package successfully, at this point, 65k problem solved.

Android Fix 65536 limit

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.