我一直在試圖爲我的應用程序構建apk文件,但是,我收到錯誤:方法引用的數量不能超過64K。無法構建apk:方法引用的數量不能超過64K
這裏有錯誤,
錯誤:方法引用的一個.DEX文件的數量不能超過64K。 瞭解如何解決此問題https://developer.android.com/tools/building/multidex.html
錯誤:執行任務':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
這是我的gradle這個文件,
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'
}
我想建立apk文件並部署它沒有任何問題,我該怎麼辦呢?
更新
我也試過以下
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'
}
這是生產的消息:
錯誤:執行失敗的任務 ':應用程序:transformClassesWithNewClassShrinkerForDebug'。
Warnings found during shrinking, please use -dontwarn or -ignorewarnings to suppress them.
我該如何處理這個問題並構建一個合適的apk?請幫忙。
http://developer.android.com/tools/building/multidex.html – camelCaseCoder
http://developer.android.com/tools/building/multidex .html 你必須啓用Multidex,請按照上面的鏈接 – Azahar