每當我建的項目,並準備發佈我的設備上,我不斷收到此錯誤:搖籃構建失敗:敏捷文件不能超過64K
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.8.0_91\bin\java.exe'' finished with non-zero exit value 2
它說gradle這個構建失敗,兩個錯誤
所以我有一些問題:
- 什麼是dex文件
- 我沒有直接使用它們,所以爲什麼我會得到上面的錯誤?
- 什麼是dex文件?
- 這些文件對於.APK文件大小有什麼要說的嗎?
這些錯誤在我停止使用proguard進行調試構建之後開始再次出現,因爲StackTrace沒有顯示,並且在激活了proguard之前,我出現了錯誤。
我以前有過這個錯誤,我刪除了dex文件夾,它解決了它,但現在它突然不夠了。
我gradle這個文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.myproject"
minSdkVersion 15
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha1'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.google.android.gms:play-services:9.2.0'
compile 'com.google.android.gms:play-services-ads:9.2.0'
}
你應該**從不**使用完整的'play-services'依賴。只能使用[選擇您需要的Play服務API](https://developers.google.com/android/guides/setup#split)。包括整個事情是64k方法限制的45k +。 – ianhanniballake