Android java.exe以非零退出值1结束

Ran*_*and 116 android jvm compiler-errors gradle

我试过看类似的,没有解决方案有效.我以前运行的应用程序没有问题,但我的新应用程序突然开始给我带来问题.当我尝试运行它时总是失败说:

Error:Execution failed for task ':app:preDexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_67\bin\java.exe'' finished with non-zero exit value 1
Run Code Online (Sandbox Code Playgroud)

以下是控制台显示的内容:

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportSupportV42200Library 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:compileDebugJava UP-TO-DATE
:app:preDexDebug
AGPBI: {"kind":"SIMPLE","text":"Error: Could not create the Java Virtual        Machine.","position":{},"original":"Error: Could not create the Java Virtual Machine."}
AGPBI: {"kind":"SIMPLE","text":"Error: A fatal exception has occurred. Program will exit.","position":{},"original":"Error: A fatal exception has occurred. Program will exit."}

AGPBI: {"kind":"SIMPLE","text":"Error: Could not create the Java Virtual Machine.","position":{},"original":"Error: Could not create the Java Virtual Machine."}
AGPBI: {"kind":"SIMPLE","text":"Error: A fatal exception has occurred. Program will exit.","position":{},"original":"Error: A fatal exception has occurred. Program will exit."}


FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDexDebug'.
com.android.ide.common.process.ProcessException:     org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_67\bin\java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.614 secs

AGPBI: {"kind":"SIMPLE","text":"Error: Could not create the Java Virtual Machine.","position":{},"original":"Error: Could not create the Java Virtual Machine."}
AGPBI: {"kind":"SIMPLE","text":"Error: A fatal exception has occurred. Program will exit.","position":{},"original":"Error: A fatal exception has occurred. Program will exit."}
Run Code Online (Sandbox Code Playgroud)

这个应用程序非常简单,我没有从库存布局改变它.它仅适用于棒棒糖,仅使用库存功能.这是build.gradle:

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

defaultConfig {
    applicationId "com.package.app"
    minSdkVersion 21
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.0.0'
}
Run Code Online (Sandbox Code Playgroud)

小智 55

遇到了由于可绘制资源冲突而导致的相同错误.我做了一个干净的项目,不再遇到错误.


小智 16

经过大量的冲浪,我发现问题是GC开销(内存不足).通过将以下代码添加到我的build.gradle节省了我的一天.

android {

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

}
Run Code Online (Sandbox Code Playgroud)

reference - ProcessException:org.gradle.process.internal.ExecException以非零退出值2结束

  • `DexOptions.incremental`已过时,将于2018年底删除 (2认同)

Ran*_*and 12

它一直是我的Java安装的问题.我删除了所有Java(C://程序文件/ Java/jdk)和jre文件夹的痕迹,并从官方页面重新安装它,现在它工作正常.


Sha*_*aun 12

也许你可以改变你的buildToolsVersion num.

这是我的问题:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\ProgramTools\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1
Run Code Online (Sandbox Code Playgroud)

我的build.gradle:

android {
    compileSdkVersion 23
    buildToolsVersion "24.0.0"

    defaultConfig {
        applicationId "com.pioneers.recyclerviewitemanimation"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我只是将buildToolsVersion更改为buildToolsVersion"23.0.2",问题解决了.


Mal*_*der 11

问题RAM.我的Messages Gradle Build中有类似的消息

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.8.0_45\bin\java.exe'' 
finished with non-zero exit value 1
Run Code Online (Sandbox Code Playgroud)

原因:我的笔记本电脑上没有OS Windows 8.1的可用内存.

解决方案:我关闭了一些我不需要的程序.在那之后,我有更多的免费RAM,我的项目是在android studio中构建的.


小智 8

在我的情况下,解决方案是关闭Android Studio并杀死java进程,这是非常大的(1.2 GB).在此之后,我的项目正常运行(OS X Mount Lion,Android Studio 1.2.2,iMac Mid 2011 4GB Ram).


SHI*_*EPH 7

1.只需清洁项目并检查其工作与否

2.关闭所有垃圾任务后,重新启动android studio

3.如果以上两点都不起作用,请在gradle.build文件中添加

android {

    dexOptions {
        incremental = true;
        preDexLibraries = false
        javaMaxHeapSize "4g" 
    }

}
Run Code Online (Sandbox Code Playgroud)


Ima*_*shi 7

使用下assembleandroidtest图所示的选项。因此,您可以了解有关发生错误的更多信息:

在此处输入图片说明


Luc*_*aka 6

将库icepick添加到我的gradle依赖项后,我遇到了同样的问题.删除依赖项后,一切似乎都没问题.一旦我知道为什么会出现这个问题,我会再次写在这里

  • 同样在这里.解决方法是使用`provided`而不是`compile`来处理`processor`依赖.见[此票证](https://github.com/frankiesardo/icepick/issues/46). (4认同)