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.
The problem as I commented is an incorrect configuration should be
multiDexEnabled = true
Wrote incorrectly
multiDexEnabled true
This would be your% corrected% file:
apply plugin: 'com.android.application' android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.kofh.mx.tae"
minSdkVersion 16
targetSdkVersion 25
versionCode 6
versionName "1.5"
// Enabling multidex support.
//multiDexEnabled true
multiDexEnabled = true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/volley.jar')
compile files('libs/ksoap2-android-assembly-3.5.0-jar-with-dependencies.jar')
compile files('libs/usbsdk.jar')
compile files('libs/jasypt-1.9.2.jar')
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-messaging:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
Update: , another problem arose that is:
Error: UNEXPECTED TOP-LEVEL ERROR: Error: java.lang.OutOfMemoryError: GC
overhead limit exceeded Error: Execution failed for task
For this, more memory has to be assigned, therefore the Heap size in the file build.gradle
is configured by means of the variable build.gradle
:
dexOptions {
javaMaxHeapSize "4g"
}