[英]Gradle build failed in Android Studio 1.5.1
I'm unable to run my app. 我无法运行我的应用程序。 Every time I'm trying to run my app in emulator Android studio shows me following error.
每次我试图在模拟器中运行我的应用程序时,Android工作室都会显示以下错误。
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\\Program Files (x86)\\Java\\jdk1.8.0_66\\bin\\java.exe'' finished with non-zero exit value 2
错误:任务执行失败':app:transformClassesWithDexForDebug'。> com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:Process'命令'C:\\ Program Files(x86)\\ Java \\ jdk1.8.0_66 \\ bin \\ java.exe''以非零退出值2结束
Here's my build.gradle
files. 这是我的
build.gradle
文件。
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.gripxtech.kasim.unipayretailer"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.malinskiy:superrecyclerview:1.1.1'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'com.codinguser.android:contactpicker:3.0.0@aar'
compile 'com.squareup.okhttp:okhttp:2.7.0'
compile project(':materialdatetimepick')
}
build.gradle(Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
I've already tried to apply solution from many question similar to mine but, still I can't solve my issue. 我已经尝试过应用类似于我的许多问题的解决方案,但是,我仍然无法解决我的问题。 Thanks in Advance.
提前致谢。
Add this to build.gradle
file: 将其添加到
build.gradle
文件:
android {
...
defaultConfig {
...
multiDexEnabled true
}
}
Here you would find an explanation why this error happened: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define 在这里你会找到解释为什么会发生这个错误的原因: 意外的顶级异常:com.android.dex.DexException:多个dex文件定义
If it wouldn't work, please delete all files and folders from: 如果它不起作用,请从以下位置删除所有文件和文件夹:
YOUR_APP_NAME\app\build\intermediates
It sometimes happens when you have duplicated dependencies with different versions 当您有不同版本的重复依赖项时,有时会发生这种情况
Try this command and check if there something twice: 尝试此命令并检查是否有两次:
./gradlew dependencies
Hope it help 希望它有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.