错误:任务':app:dexDebug'执行失败。 >完成非零退出值1

时间:2016-09-13 16:41:45

标签: android

我已经面临这个错误超过2天了 可以告诉我们这段代码的错误吗

错误:任务':app:dexDebug'执行失败。

  

com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令' C:\ Program Files \ Java \ jdk1.7.0_25 \ bin \的java.exe''完成非零退出值1 **

这里我根据其他stackoverflow提交(一个接一个)尝试了 1.添加了dexOptions
2. multiDexEnabled = true
3.清洁项目
4.将SDK 1.7.0_25更改为1.7.0_79
5.将gradle build更改为1.3.0到1.5.0


我的应用程序gradle文件

apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.foodyroute.food"
    minSdkVersion 11
    targetSdkVersion 22
    versionCode 1
    versionName "1.01"
    multiDexEnabled true

}
dexOptions {
    incremental = true;
    preDexLibraries = false
    javaMaxHeapSize "4g" // 2g should be also OK
}


repositories {
    mavenCentral()
    jcenter()

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),       'proguard-rules.pro'
    }
}
sourceSets {
    main {
        res.srcDirs = ['src/main/res', 'src/main/res/anim']
        renderscript.srcDirs = ['src/main/rs', 'src/main/rs/']
    }
  }
}
dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   compile 'com.android.support:appcompat-v7:22.2.1'
   compile 'com.android.support:design:22.2.1'
   compile 'com.android.support:recyclerview-v7:+'
   compile 'com.google.android.gms:play-services-location:8.1.0'
   compile 'com.android.support:cardview-v7:23.2.0'



}

这是Project Build Gradle

buildscript {
  repositories {
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:1.3.0'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
}

allprojects {
  repositories {
       jcenter()
  }
}

这是控制台所说的

:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE`
:app:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE    
:app:prepareComAndroidSupportCardviewV72320Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2221Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72420Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2420Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2420Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42221Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase810Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement810Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation810Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps810Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:dexDebug
 UNEXPECTED TOP-LEVEL EXCEPTION:
 java.lang.IllegalArgumentException: already added:         Landroid/support/v4/app/NotificationCompatBase$UnreadConversation;
    at        com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:732)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added:         Landroid/support/v4/hardware/display/DisplayManagerCompat$LegacyImpl;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:732)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
at     com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at     com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
2 errors; aborting
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException:     org.gradle.process.internal.ExecException: Process 'command 'C:\Program     Files\Java\jdk1.7.0_25\bin\java.exe'' finished with non-zero exit value 1

1 个答案:

答案 0 :(得分:0)

您的支持库存在冲突。您的CardView是23.2,您的RecyclerView始终是最新版本,现在是24.2.x.

尝试使您的支持库版本匹配。

compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'

最简单的方法,

(注意:我不确定22.2.1版本的这些库的可用性,具体而言)

ext {
    // Variables to keep libraries consistent
    supportLibrary = "22.2.1"
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile "com.android.support:appcompat-v7:${supportLibrary}"
    compile "com.android.support:design:${supportLibrary}"
    compile "com.android.support:recyclerview-v7:${supportLibrary}"
    compile "com.android.support:cardview-v7:${supportLibrary}"
}

您可能还想将Gradle插件更新到最新版本

classpath 'com.android.tools.build:gradle:2.1.3'

gradle/gradle-wrapper.properties中,请确保您拥有2.14.1

distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip