每当我建的项目,并准备发布我的设备上,我不断收到此错误:摇篮构建失败:敏捷文件不能超过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