Storg Storg - 2 months ago 59
Android Question

Error:The number of method references in a .dex file cannot exceed 64K.6

I want to build apk file, but i cant, because i have 2 errors. I tried lots of solutions, for example multiDexEnabled true or something like that, but didnt work.. Please help:)

Errors:

Error:The number of method references in a .dex file cannot exceed 64K.
Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html
:app:transformClassesWithDexForDebug FAILED

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.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_92\bin\java.exe'' finished with non-zero exit value 2


Gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.1"

defaultConfig {
applicationId "sgtt.celtkituzes_0_1"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.volley:volley:1.0.0'
compile 'com.backendless:backendless:3.0.20.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.firebaseui:firebase-ui-database:0.5.1'
compile 'com.google.firebase:firebase-core:9.4.0'
}
apply plugin: 'com.google.gms.google-services'

Answer

You shouldn't ever be using compile 'com.google.android.gms:play-services:9.4.0' as that includes every Google Play services library - only use the APIs you need.

This should reduce your method count enough to fit under the 64K limit.