ProcessException:org.gradle.process.internal.ExecException以非零退出值2

时间:2015-10-22 09:03:03

标签: java android gradle android-gradle build.gradle

今天我在尝试构建我的项目后遇到了这个构建错误,但我什么都没改变,它只是突然冒出来......或者我根本不记得我拥有的东西改变。我做了一件事,更新了构建工具,但我根本不使用最新的,所以它应该打扰项目。

错误:

Error:Execution failed for task ':DoToDoCourierApp:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: 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 2

完整日志:

Information:Gradle tasks [:DoToDoCourierApp:generateDebugSources, :DoToDoCourierApp:generateDebugAndroidTestSources, :DoToDoCourierApp:assembleDebug]
:DoToDoCourierApp:preBuild UP-TO-DATE
:DoToDoCourierApp:preDebugBuild UP-TO-DATE
:DoToDoCourierApp:checkDebugManifest
:DoToDoCourierApp:preReleaseBuild UP-TO-DATE
:DoToDoEssentials:preBuild UP-TO-DATE
:DoToDoEssentials:preReleaseBuild UP-TO-DATE
:DoToDoEssentials:compileReleaseNdk UP-TO-DATE
:DoToDoEssentials:compileLint
:DoToDoEssentials:copyReleaseLint UP-TO-DATE
:DoToDoEssentials:checkReleaseManifest
:DoToDoEssentials:preDebugAndroidTestBuild UP-TO-DATE
:DoToDoEssentials:preDebugBuild UP-TO-DATE
:DoToDoEssentials:preDebugUnitTestBuild UP-TO-DATE
:DoToDoEssentials:preReleaseUnitTestBuild UP-TO-DATE
:DoToDoEssentials:prepareComAndroidSupportAppcompatV72310Library UP-TO-DATE
:DoToDoEssentials:prepareComAndroidSupportDesign2310Library UP-TO-DATE
:DoToDoEssentials:prepareComAndroidSupportMediarouterV72220Library UP-TO-DATE
:DoToDoEssentials:prepareComAndroidSupportRecyclerviewV72310Library UP-TO-DATE
:DoToDoEssentials:prepareComAndroidSupportSupportV132310Library UP-TO-DATE
:DoToDoEssentials:prepareComAndroidSupportSupportV42310Library UP-TO-DATE
:DoToDoEssentials:prepareComFacebookAndroidFacebookAndroidSdk460Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServices810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesAds810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesAnalytics810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesAppinvite810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesAppstate810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesBase810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesBasement810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesCast810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesDrive810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesFitness810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesGames810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesGcm810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesIdentity810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesLocation810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesMaps810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesMeasurement810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesNearby810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesPanorama810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesPlus810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesSafetynet810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesVision810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesWallet810Library UP-TO-DATE
:DoToDoEssentials:prepareComGoogleAndroidGmsPlayServicesWearable810Library UP-TO-DATE
:DoToDoEssentials:prepareDeHdodenhofCircleimageview200Library UP-TO-DATE
:DoToDoEssentials:prepareReleaseDependencies
:DoToDoEssentials:compileReleaseAidl UP-TO-DATE
:DoToDoEssentials:compileReleaseRenderscript UP-TO-DATE
:DoToDoEssentials:generateReleaseBuildConfig UP-TO-DATE
:DoToDoEssentials:generateReleaseAssets UP-TO-DATE
:DoToDoEssentials:mergeReleaseAssets UP-TO-DATE
:DoToDoEssentials:generateReleaseResValues UP-TO-DATE
:DoToDoEssentials:generateReleaseResources UP-TO-DATE
:DoToDoEssentials:mergeReleaseResources
AAPT err(Facade for 1745997574): C:\android_studio_works\DoToDo_as\DoToDoEssentials\src\main\res\drawable-xhdpi\avatar_blank.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT err(Facade for 967998735): C:\android_studio_works\DoToDo_as\DoToDoEssentials\src\main\res\drawable-xhdpi\logo_login.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT err(Facade for 1796841709): C:\android_studio_works\DoToDo_as\DoToDoEssentials\src\main\res\drawable-xhdpi\car_avatar_blank.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT err(Facade for 1504354275): C:\android_studio_works\DoToDo_as\DoToDoEssentials\src\main\res\drawable\login_splash.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
:DoToDoEssentials:processReleaseManifest UP-TO-DATE
:DoToDoEssentials:processReleaseResources UP-TO-DATE
:DoToDoEssentials:generateReleaseSources UP-TO-DATE
:DoToDoEssentials:compileReleaseJavaWithJavac UP-TO-DATE
:DoToDoEssentials:extractReleaseAnnotations UP-TO-DATE
:DoToDoEssentials:mergeReleaseProguardFiles UP-TO-DATE
:DoToDoEssentials:processReleaseJavaRes UP-TO-DATE
:DoToDoEssentials:packageReleaseJar UP-TO-DATE
:DoToDoEssentials:packageReleaseJniLibs UP-TO-DATE
:DoToDoEssentials:packageReleaseLocalJar UP-TO-DATE
:DoToDoEssentials:packageReleaseRenderscript UP-TO-DATE
:DoToDoEssentials:packageReleaseResources
:DoToDoEssentials:bundleRelease UP-TO-DATE
:DoToDoCourierApp:prepareComAndroidSupportAppcompatV72310Library UP-TO-DATE
:DoToDoCourierApp:prepareComAndroidSupportDesign2310Library UP-TO-DATE
:DoToDoCourierApp:prepareComAndroidSupportMediarouterV72220Library UP-TO-DATE
:DoToDoCourierApp:prepareComAndroidSupportRecyclerviewV72310Library UP-TO-DATE
:DoToDoCourierApp:prepareComAndroidSupportSupportV132310Library UP-TO-DATE
:DoToDoCourierApp:prepareComAndroidSupportSupportV42310Library UP-TO-DATE
:DoToDoCourierApp:prepareComFacebookAndroidFacebookAndroidSdk460Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServices810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesAds810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesAnalytics810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesAppindexing810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesAppinvite810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesAppstate810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesBase810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesBasement810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesCast810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesDrive810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesFitness810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesGames810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesGcm810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesIdentity810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesLocation810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesMaps810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesMeasurement810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesNearby810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesPanorama810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesPlus810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesSafetynet810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesVision810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesWallet810Library UP-TO-DATE
:DoToDoCourierApp:prepareComGoogleAndroidGmsPlayServicesWearable810Library UP-TO-DATE
:DoToDoCourierApp:prepareDeHdodenhofCircleimageview200Library UP-TO-DATE
:DoToDoCourierApp:prepareDoToDo_asDoToDoEssentialsUnspecifiedLibrary UP-TO-DATE
:DoToDoCourierApp:prepareDebugDependencies
:DoToDoCourierApp:compileDebugAidl UP-TO-DATE
:DoToDoCourierApp:compileDebugRenderscript UP-TO-DATE
:DoToDoCourierApp:generateDebugBuildConfig UP-TO-DATE
:DoToDoCourierApp:generateDebugAssets UP-TO-DATE
:DoToDoCourierApp:mergeDebugAssets UP-TO-DATE
:DoToDoCourierApp:generateDebugResValues UP-TO-DATE
:DoToDoCourierApp:processDebugGoogleServices
:DoToDoCourierApp:generateDebugResources
:DoToDoCourierApp:mergeDebugResources UP-TO-DATE
:DoToDoCourierApp:processDebugManifest UP-TO-DATE
:DoToDoCourierApp:processDebugResources UP-TO-DATE
:DoToDoCourierApp:generateDebugSources UP-TO-DATE
:DoToDoCourierApp:preDebugAndroidTestBuild UP-TO-DATE
:DoToDoCourierApp:prepareDebugAndroidTestDependencies
:DoToDoCourierApp:compileDebugAndroidTestAidl UP-TO-DATE
:DoToDoCourierApp:processDebugAndroidTestManifest UP-TO-DATE
:DoToDoCourierApp:compileDebugAndroidTestRenderscript UP-TO-DATE
:DoToDoCourierApp:generateDebugAndroidTestBuildConfig UP-TO-DATE
:DoToDoCourierApp:generateDebugAndroidTestAssets UP-TO-DATE
:DoToDoCourierApp:mergeDebugAndroidTestAssets UP-TO-DATE
:DoToDoCourierApp:generateDebugAndroidTestResValues UP-TO-DATE
:DoToDoCourierApp:generateDebugAndroidTestResources UP-TO-DATE
:DoToDoCourierApp:mergeDebugAndroidTestResources UP-TO-DATE
:DoToDoCourierApp:processDebugAndroidTestResources UP-TO-DATE
:DoToDoCourierApp:generateDebugAndroidTestSources UP-TO-DATE
:DoToDoCourierApp:compileDebugJavaWithJavac UP-TO-DATE
:DoToDoCourierApp:compileDebugNdk UP-TO-DATE
:DoToDoCourierApp:compileDebugSources UP-TO-DATE
:DoToDoCourierApp:transformClassesAndResourcesWithExtractJarsForDebug UP-TO-DATE
:DoToDoCourierApp:transformClassesWithDexForDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':DoToDoCourierApp:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: 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 2

我有3个模块。第一个基本上是一个库'持有者'它包含所有已编译的库。另外两个是使用库的2个应用程序。

  • DoToDoEssentials:库模块,包含所有已编译的库
  • DoToDoCourier:App模块
  • DoToDoSender:App模块

以下是gradle文件:

项目的顶级build.gradle:

// 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.3.1'
        classpath 'com.google.gms:google-services:1.4.0-beta3'

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

}

allprojects {
    repositories {
        jcenter()
    }
}

DoToDoEssentials模块gradle文件:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"


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

repositories { mavenCentral() }


dependencies {
    compile 'com.android.support:appcompat-v7:23.+' //appcompat activity for navigation drawer
    compile 'com.android.support:design:23.+' //support for pre Android L desing views
    compile 'com.android.support:support-v13:23.+' //support for pre Android L other
    compile 'com.google.android.gms:play-services:8.1.0' //google maps
    compile 'com.facebook.android:facebook-android-sdk:4.6.0' //facebook lib
    compile 'de.hdodenhof:circleimageview:2.0.0' //circle image view
    compile 'com.squareup.picasso:picasso:2.5.2' //image downloader lib
    compile 'com.google.code.gson:gson:2.4' //gson for serialization
    compile 'com.squareup.okhttp:okhttp-android-support:2.5.0'  //networking lib bugfix lib ..? kell ez ?
    compile 'com.squareup.okio:okio:1.6.0'  //okhttp dependency
    compile 'com.squareup.okhttp:okhttp:2.5.0'   //networking lib
    compile 'com.googlecode.libphonenumber:libphonenumber:5.5' //phone number validation library


    compile fileTree(dir: 'libs', include: ['*.jar'])


}

DoToDoCourier app gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.illion.dotodo.application.courier"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}


repositories { mavenCentral() }

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':DoToDoEssentials')
}

DoToDoSender App gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.illion.dotodo.application.sender"
        minSdkVersion 19
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


repositories { mavenCentral() }

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':DoToDoEssentials')
}

我已经使用了这个方案好几个月了,它已经工作了,现在发生了一些事情,我不能没有错误地构建。

那么我应该怎么做:

ProcessException:org.gradle.process.internal.ExecException:进程'命令' C:\ Program Files \ Java \ jdk1.8.0_45 \ bin \ java.exe'& #39;完成非零退出值2

没有提示,没有具体错误,只是例外。

我尝试了什么:

  • 清理项目
  • 重建项目
  • 运行项目
  • 使缓存无效/重新启动
  • 加载较旧的提交

但问题仍然存在。

我使用Android Studio 1.4

如果可以,请帮忙。

1 个答案:

答案 0 :(得分:3)

370次观看,一个月后仍然没有回复。

我能够重现您在更新构建工具或尝试使您的应用程序多索引之后发生的这种奇怪的事情。你通常会得到一些不会告诉你太多的TransformException(gradle内部异常),但是在用--info --debug编译之后,你可能会注意到GC开销是一个错误(它是'失去了记忆。

对于内存限制的修复,您可以在SO:Android Studio Google JAR file causing GC overhead limit exceeded error上查看相关的线程,但是如果您需要快速修复,请将此javaMaxHeapSize添加到您的dexOptions中,如下所示:

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

PS:有关选项的一些解释,请参阅此主题:how can I use Android dexOptions?