【发布时间】:2016-05-17 09:51:55
【问题描述】:
几天前,我升级了我的 Android Studio,现在我遇到了一个问题。
实际上,我正在尝试从我的项目构建一个 APK 文件以在真实设备上测试我的应用程序,当我单击 Build--> Build Apk 时,我在 Message Gradle 中收到了几个错误建造。我不知道为什么会出现这些错误,请详细说明原因。
错误
错误:将字节码转换为 dex 时出错:
原因:com.android.dex.DexException: 多个dex文件定义Lcom/android/volley/VolleyError;错误:任务 ':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_51\bin\java.exe'' 以非零退出值 2 结束
build.gradle 文件
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.dovezeal.gapp"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
//compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:design:23.1.1'
// Volley
compile 'com.android.volley:volley:1.0.0'
//compile 'com.mcxiaoke.volley:library:1.0.+'
/* compile files('libs/com.mcxiaoke.volley library-1.0.0.jar')*/
// RecyclerView
compile 'com.android.support:recyclerview-v7:23.0.+'
// A simple way to define and render UI specs on top of your Android UI.
compile 'org.lucasr.dspec:dspec:0.1.1'
compile files('libs/library-1.0.0.jar')
// YouTube Player
compile files('libs/YouTubeAndroidPlayerApi.jar')
// GOSN
/* compile files('libs/gson-2.2.3.jar')*/
}
编辑 - 1
正如 janki gadhiya 在下面的评论中所说,更改 minifyEnabled true 并尝试在 defaultConfig 下添加 multiDexEnabled true
通过这些更改,上面的两个错误都消失了,但现在出现了以下错误。
- 错误:任务执行失败:app:transformClassesWithJarMergingForDebug' com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:com/android/volley/Request$Priority.class
【问题讨论】:
-
更改
minifyEnabled true并尝试在defaultConfig下添加multiDexEnabled true。 -
@jankigadhiya 感谢您的帮助!请同时检查我的问题中的 Edit-1 部分,并解释这些错误的实际原因
标签: android apk build.gradle