Error: The number of method references in a. file can not exceed 64K

1

I am working with android in an app that is developed for android 5 onwards the problem is that you want to make it compatible with 4.4.2 and when you run the apk on a device 4.4.2 the following error is displayed.

Error: The number of method references in a .dex file can not exceed 64K. Learn how to solve this issue at link Error: Execution failed for task ': app: transformClassesWithDexForDebug'.

  

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException

the gradle of the app is the following

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.0'
    defaultConfig {
        applicationId "xxx.xxxxxxxxx.xxxx.xxxx"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

    }
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_7
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    provided 'org.roboguice:roboblender:3.0.1'
    compile files('libs/volley.jar')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'de.greenrobot:greendao:1.3.7'
    compile 'org.roboguice:roboguice:3.0.1'
    compile 'com.mixpanel.android:mixpanel-android:4.6.4'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.facebook.fresco:fresco:0.9.0'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.google.android.gms:play-services-ads:9.4.0'
    compile 'com.google.android.gms:play-services-auth:9.4.0'
    compile 'com.google.android.gms:play-services-gcm:9.4.0'

}

add what the league shows and it just does not work for me, I hope you can help.

    
asked by Alan Mex 10.04.2017 в 23:07
source

1 answer

0
  

Error: The number of method references in a .dex file can not exceed   64K. Learn how to solve this issue at

This is solved by enabling multidex from your build.gradle :

android {

    defaultConfig {
        ...
        ...
        multiDexEnabled = true
    } 
}

Review the documentation document: Set up your app for Multidex with gradle .

  

The Android application files (APK) contain files for   Byte code executable in the form of Dalvik Executable files   (Dex), which contain the compiled code used to execute your   app The Dalvik Executable specification limits the total amount   of methods that can be referenced in a Dex file to 65   536, including the methods of the Android framework, library and   of your own code. In the context of computing, the term   Kilo, K, denotes 1024 (or 2 ^ 10). Because 65 536 equals 64 X   1024, this limit is called "64K reference limit" .

     

To overcome this limit, you must configure the compilation process   of your app to generate more than one Dex file, which is known as   MultiDex configuration.

   defaultConfig {
        applicationId "xxx.xxxxxxxxx.xxxx.xxxx"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

        multiDexEnabled = true //*** Agregar!
    }
    
answered by 11.04.2017 в 00:00