dex loader unable to execute dex: method ID not in [0, 0xffff]: 65536

前端 未结 6 1236
后悔当初
后悔当初 2020-12-15 10:44

iam building my application i got this error

Dx warning: Ignoring InnerClasses attribute for an anonymous inner class (com.amazonaws.javax.xml.stream.xerces.util.Se

6条回答
  •  攒了一身酷
    2020-12-15 10:54

    You get this error mainly because there is a limitation on dalvik executable files and apparently the limit is 65536 which is 2^16.

    You have to enable multi-dex configuration for your android application. To enable multi-dex, follow these steps:

    1. Edit your build.gradle file of your main module (app)

       android {
        defaultConfig {
          ...
         multiDexEnabled  true
       }
      }
      
      dependencies {
          ...
        compile 'com.android.support:multidex:1.0.1'
      }
      
    2. Tell your application class to handle these changes.

      You can edit your custom application class to enable multi-dex support.

      public class MyApplication extends Application {
      
      @Override
      protected void attachBaseContext(Context base) {
         super.attachBaseContext(base);
         MultiDex.install(this);
       }
      }
      

      OR

      public class MyApplication extends MultiDexApplication{
      
      }
      

      OR

      Edit your AndroidManifest.xml file to apply your changes to the application tag

              
      
         
           ...
         
      

    There are limitation below API Level 14 and below. Your app may not compile or run below API level 14. While compiling you can get OutOfMemory exception. To resolve this, add the following to build.gradle

    dexOptions {
        jumboMode true
        javaMaxHeapSize "4g"
    }
    

提交回复
热议问题