Android resolution number 65536 (65k) limit

Source: Internet
Author: User

Error messages that may appear:

Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536

Description: This method is provided by Google. Links are as follows:
Https://developer.android.com/studio/build/multidex.html

Steps to resolve:

1. Step 1:

android { compileSdkVersion 21 buildToolsVersion "21.1.0"defaultConfig {    ...    minSdkVersion 14    targetSdkVersion 21    ...    // Enabling multidex support.    multiDexEnabled true}...}dependencies { compile ‘com.android.support:multidex:1.0.0‘ }

2. Step 2:

Let the app support multiple Dex files. Three optional methods are described in Multidexapplication Javadoc:

1. Statement in Androidmanifest.xml's application

android.support.multidex.MultiDexApplication;

2. If you already have your own application class, let it inherit multidexapplication;

3. If your application class has been inherited from another class and you do not want/can modify it, then you can override the Attachbasecontext () method:

@Override protected void attachBaseContext(Context base) {    super.attachBaseContext(base); MultiDex.install(this);}
Postscript:

Multidex still have some limitations:

      1. Dex files are very complex to install to a device, and if the second Dex file is too large, it can cause the app to be unresponsive. You should use Proguard to reduce the size of the Dex file.

      2. Due to Dalvik linearalloc bugs, apps may not start in versions prior to Android 4.0, and if your app wants to support these versions, it will run more tests.

      3. Also because of the limitations of Dalvik Linearalloc, requests for large amounts of memory can cause crashes. Dalvik Linearalloc is a fixed-size buffer. During the installation of the app, a program called Dexopt is run to prepare the app for running in the current model. Dexopt uses Linearalloc to store the application's method information. Android 2.2 and 2.3 buffers only 5mb,android 4.x increased to 8MB or 16MB. Dexopt crashes when too many methods result in exceeding the buffer size.
        The Multidex build tool also does not support specifying which classes must be included in the first Dex file, so it is possible that some class libraries (such as a class library that needs to access Java code from native code) cannot be used.

Android resolution number 65536 (65k) 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.