Android Studio Build失败,异常执行失败':app:dexDebug'

时间:2015-03-31 07:28:33

标签: java android compilation

控制台日志:

  

FAILED

     

失败:构建因异常而失败。

     
      
  • 出了什么问题:任务执行失败':app:dexDebug'。

         
        

    com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:Process'命令     ' C:\ Program Files(x86)\ Java \ jdk1.8.0 \ bin \ java.exe''完成了     非零退出值2

      
  •   
  • 尝试:使用--info或--debug选项运行以获取更多日志输出。

  •   
  • 异常是:org.gradle.api.tasks.TaskExecutionException:任务':app:dexDebug'执行失败。在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)   在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)   在   org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)   在   org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)   在   org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)   在   org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)   在   org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)   在   org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)   在   org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)   在   org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)   在   org.gradle.execution.taskgraph.Abs​​tractTaskPlanExecutor $ TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)   在   org.gradle.execution.taskgraph.Abs​​tractTaskPlanExecutor $ TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)   在   org.gradle.execution.taskgraph.Abs​​tractTaskPlanExecutor $ TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)   在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)   在   org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)   在   org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)   在   org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)   在   org.gradle.execution.DefaultBuildExecuter.access $ 200(DefaultBuildExecuter.java:23)   在   org.gradle.execution.DefaultBuildExecuter $ 2.proceed(DefaultBuildExecuter.java:68)   在   org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)   在   org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)   在   org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)   在   org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)   在   org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)   在   org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)   在   org.gradle.launcher.exec.InProcessBuildActionExecuter $ DefaultBuildController.run(InProcessBuildActionExecuter.java:80)   在   org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:43)   在   org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:30)   在   org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:119)   在   org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)   在   org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)   在   org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47)   在   org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)   在   org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)   在   org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35)   在   org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)   在   org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)   在   org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)   在   org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)   在   org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)   在   org.gradle.launcher.daemon.server.exec.ForwardClientInput $ 2.call(ForwardClientInput.java:71)   在   org.gradle.launcher.daemon.server.exec.ForwardClientInput $ 2.call(ForwardClientInput.java:69)   在org.gradle.util.Swapper.swap(Swapper.java:38)at   org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69)   在   org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)   在   org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)   在   org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)   在   org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)   在   org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:70)   在   org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)   在   org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)   在   org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39)   在   org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119)   在   org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy $ 1.run(StartBuildOrRespondWithBusy.java:46)   在   org.gradle.launcher.daemon.server.DaemonStateCoordinator $ 1.run(DaemonStateCoordinator.java:246)   在   org.gradle.internal.concurrent.DefaultExecutorFactory $ StoppableExecutorImpl $ 1.run(DefaultExecutorFactory.java:64)   引起:org.gradle.internal.UncheckedException:   com.android.ide.common.process.ProcessException:   org.gradle.process.internal.ExecException:进程'命令   ' C:\ Program Files(x86)\ Java \ jdk1.8.0 \ bin \ java.exe''完成了   非零退出值2 at   org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:39)   在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:66)   在   org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ IncrementalTask​​Action.doExecute(AnnotationProcessingTaskFactory.java:235)   在   org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)   在   org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ IncrementalTask​​Action.execute(AnnotationProcessingTaskFactory.java:222)   在   org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)   在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)   在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)   ... 55更多引起:   com.android.ide.common.process.ProcessException:   org.gradle.process.internal.ExecException:进程'命令   ' C:\ Program Files(x86)\ Java \ jdk1.8.0 \ bin \ java.exe''完成了   非零退出值2 at   com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:42)   在   com.android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1193)   在   com.android.builder.core.AndroidBuilder $ convertByteCode $ 0.call(未知   来源)at   com.android.build.gradle.tasks.Dex.doTaskAction(Dex.groovy:151)at at   com.android.build.gradle.tasks.Dex.this $ 5 $ doTaskAction(Dex.groovy)at at   com.android.build.gradle.tasks.Dex $这$ 5 $ doTaskAction.callCurrent(未知   来源)at   com.android.build.gradle.tasks.Dex.taskAction(Dex.groovy:90)at at   org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)...   61更多引起:org.gradle.process.internal.ExecException:进程   '命令' C:\ Program Files(x86)\ Java \ jdk1.8.0 \ bin \ java.exe''完   非零退出值2 at   org.gradle.process.internal.DefaultExecHandle $ ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:365)   在   com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:40)   ... 68更多

  •   

build.gradle文件:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "22.0.0"

    defaultConfig {
        applicationId "com.appdomain.appname"
        minSdkVersion 15
        targetSdkVersion 21
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    }

    dependencies {
        compile 'com.android.support:support-v4:19.1.+'
        compile 'com.google.guava:guava:10.0.1'
        compile 'com.google.android.gms:play-services:+'
        compile 'com.android.support:appcompat-v7:21.0.3'
        compile files('libs/gdata-client-1.0.jar')
        compile files('libs/gdata-client-meta-1.0.jar')
        compile files('libs/gdata-contacts-3.0.jar')
        compile files('libs/gdata-contacts-meta-3.0.jar')
        compile files('libs/gdata-core-1.0.jar')
        compile files('libs/libGoogleAnalyticsServices.jar')
        compile files('libs/mpandroidchartlibrary-1-7-4.jar')
        compile files('libs/recyclerview.jar')
    }

3 个答案:

答案 0 :(得分:6)

我找到了解决方案

只需更改

compile 'com.android.support:support-v4:19.1.+'

compile 'com.android.support:support-v4:22.0.0'

也改变了

compile 'com.android.support:appcompat-v7:21.0.3'

compile 'com.android.support:appcompat-v7:22.0.0'

在build.gradle文件中使用Multi-dex属性,如下所示:

defaultConfig {
    applicationId "com.sendpulse.sendpulse"
    minSdkVersion 15
    targetSdkVersion 21
    multiDexEnabled true

}

然后清理项目并重建

答案 1 :(得分:0)

我也有类似的问题。我取出每个罐子并逐个检查,直到找到它为止 基本上这个问题是由jar文件引起的。 所以,试试这个, 将您的jar文件逐个放入依赖项并进行测试。您可以轻松获得修复。

答案 2 :(得分:0)

  1. 进行项目清理。转到Build-> Clean Project并再试一次
  2. 如果(1)不起作用,请关闭并重新启动编译器。
  3. 快速检查Build.Grade文件,确保只保留重要文件,并删除未使用的文件。
  4. 如果其他所有方法都失败了,请添加" multiDexEnabled true"到您的应用级Build.Gradle文件。
  5. 这样做:

    defaultConfig {
        applicationId "com.yourcompanyname.yourappname"
        minSdkVersion 21
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    
        // Enabling multidex support.
        multiDexEnabled true
    }