Aaron Waller
Aaron Waller

Reputation: 315

How can i solve this error? Method ID not in [0, 0xffff]: 65536

I created a new Android Studio project with a MapsActivity, if i try to launch the app on my Huawei P8 Lite device this error appears:

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

my Build.Gradle(Module: app):

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 25
        buildToolsVersion "24.0.2"
        defaultConfig {
            applicationId "com.example.de.maptestdel"
            minSdkVersion 15
            targetSdkVersion 25
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:25.1.0'
        compile 'com.google.android.gms:play-services:10.0.1'
        compile 'com.android.support:design:25.1.0'
        testCompile 'junit:junit:4.12'
    }

Is there another way to solve it except enabling Multidex? I heard that it's not so good to activate it.

Upvotes: 1

Views: 2164

Answers (1)

Mayur Gangurde
Mayur Gangurde

Reputation: 1562

Use specific/individual API from Google Play Services library. You have used compile 'com.google.android.gms:play-services:10.0.1' and this library method count is 79958.

Refer this link : https://developers.google.com/android/guides/setup

In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.

From version 6.5, you can instead selectively compile Google Play service APIs into your app.

For e.g.

For Google Maps, use :

com.google.android.gms:play-services-maps:10.0.1

method count : 17984

For Google Cloud Messaging :

com.google.android.gms:play-services-gcm:10.0.1

method count : 15784

So, using individual API will reduced apk method count. Then, no need to enable multidex.

Upvotes: 3

Related Questions