Android Studio DexIndexOverflowException: method ID not in

前端 未结 8 1803
长情又很酷
长情又很酷 2020-12-04 13:56

I use Android Studio to develop an application and I face this error which I have no idea how to solve.

com.android.dex.DexIndexOverflowException: met

相关标签:
8条回答
  • 2020-12-04 14:36

    set multiDex in your gradle

    defaultConfig {
        // ...
        multiDexEnabled true
    }
    

    it's work for me.

    0 讨论(0)
  • 2020-12-04 14:41

    Best way use individual package under the list of all google services package.

    Google Play services API                Description in build.gradle                                       
    Google+                                            com.google.android.gms:play-services-plus:11.2.0
    Google Account Login                      com.google.android.gms:play-services-auth:11.2.0
    Google Actions, Base Client Librarycom.google.android.gms:play-services-base:11.2.0
    Google Address                                API com.google.android.gms:play-services-identity:11.2.0
    Google Analytics                              com.google.android.gms:play-services-analytics:11.2.0
    Google Awareness                          com.google.android.gms:play-services-awareness:11.2.0
    Google Cast                                    com.google.android.gms:play-services-cast:11.2.0
    Google Cloud Messaging                com.google.android.gms:play-services-gcm:11.2.0
    Google Drive                                  com.google.android.gms:play-services-drive:11.2.0
    Google Fit                                       com.google.android.gms:play-services-fitness:11.2.0
    Google Location and Activity Recognition com.google.android.gms:play-services-location:11.2.0
    Google Maps com.google.android.gms:play-services-maps:11.2.0
    Google Mobile Ads     com.google.android.gms:play-services-ads:11.2.0
    Google Places com.google.android.gms:play-services-places:11.2.0
    Mobile Vision com.google.android.gms:play-services-vision:11.2.0
    Google Nearby com.google.android.gms:play-services-nearby:11.2.0
    Google Panorama Viewer com.google.android.gms:play-services-panorama:11.2.0
    Google Play Game services com.google.android.gms:play-services-games:11.2.0
    SafetyNet com.google.android.gms:play-services-safetynet:11.2.0
    Android Pay com.google.android.gms:play-services-wallet:11.2.0
    Android Wear com.google.android.gms:play-services-wearable:11.2.0

    0 讨论(0)
  • 2020-12-04 14:41
        Error:Execution failed for task ':app: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
    
    
    solution : inside build.gradle(app)
    defaultConfig {
            applicationId "com.rentalhousereviews"
            ------------
            -----------
            multiDexEnabled true  //add this line
        }
    
    
    
    dependencies {
    compile 'com.android.support:multidex:1.0.1'
    }
    
    0 讨论(0)
  • 2020-12-04 14:41

    Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.

    com.android.build.api.transform.TransformException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

    Latest version com.android.support:multidex:1.0.3 worked for me!

    dependencies {
      compile 'com.android.support:multidex:1.0.3'
    }
    
    0 讨论(0)
  • 2020-12-04 14:44

    Android has a pre-defined upper limit of Methods of 65536.

    if you added play services as whole please remove it and add specific ones.

    remove compile 'com.google.android.gms:play-services:9.6.1' and then add ex: compile 'com.google.android.gms:play-services-maps:9.6.1' for maps.

    https://developers.google.com/android/guides/setup

    shows a list of the separate APIs that you can include when compiling your app, and how to describe them in your build.gradle file

    0 讨论(0)
  • 2020-12-04 14:44

    DexIndexOverflowException is also caused by exceeding 65536 methods. This can easily happen when adding a large library such as Google Play services. See this answer for a solution.

    0 讨论(0)
提交回复
热议问题