I have been trying to build the apk file for my app, however, I am getting the error: The number of method references cannot exceed 64K.
Here are the 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
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.7.0_15\bin\java.exe'' finished with non-zero exit value 2
This is my gradle file,
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "nikhilraghavendra.hopper"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.google.android.gms:play-services:8.4.0'
}
I want to build the apk file and deploy it without any issues, how do I do it?
Update
I also tried the following
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
dexOptions {
maxProcessCount = 4 // this is the default value
}
dataBinding{
enabled = true
}
defaultConfig {
applicationId "nikhilraghavendra.hopper"
minSdkVersion 21
targetSdkVersion 23
resConfigs "en", "fr"
versionCode 1
versionName "1.0"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
debug {
minifyEnabled true
useProguard false
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.google.android.gms:play-services:8.4.0'
}
This is producing the message:
Error:Execution failed for task ':app:transformClassesWithNewClassShrinkerForDebug'.
Warnings found during shrinking, please use -dontwarn or -ignorewarnings to suppress them.
How do I deal with this and build a proper apk? Please Help.