java.exe以非退出值2

时间:2016-01-11 09:58:09

标签: android android-studio gradle

当我尝试运行我的应用程序时,出现以下错误:

    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\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 2

我尝试过搜索几个论坛,但与此问题相关的大多数解决方案似乎非常具有情境性,并且没有一个解决方案适用于我。

以下显示的是我的消息gradle build中的信息:

    Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:libraries:tess-two:preBuild UP-TO-DATE
:libraries:tess-two:preReleaseBuild UP-TO-DATE
:libraries:tess-two:compileReleaseNdk UP-TO-DATE
:libraries:tess-two:compileLint
:libraries:tess-two:copyReleaseLint UP-TO-DATE
:libraries:tess-two:mergeReleaseProguardFiles UP-TO-DATE
:libraries:tess-two:packageReleaseRenderscript UP-TO-DATE
:libraries:tess-two:checkReleaseManifest
:libraries:tess-two:prepareReleaseDependencies
:libraries:tess-two:compileReleaseRenderscript UP-TO-DATE
:libraries:tess-two:generateReleaseResValues UP-TO-DATE
:libraries:tess-two:generateReleaseResources UP-TO-DATE
:libraries:tess-two:packageReleaseResources UP-TO-DATE
:libraries:tess-two:compileReleaseAidl UP-TO-DATE
:libraries:tess-two:generateReleaseBuildConfig UP-TO-DATE
:libraries:tess-two:generateReleaseAssets UP-TO-DATE
:libraries:tess-two:mergeReleaseAssets UP-TO-DATE
:libraries:tess-two:processReleaseManifest UP-TO-DATE
:libraries:tess-two:processReleaseResources UP-TO-DATE
:libraries:tess-two:generateReleaseSources UP-TO-DATE
:libraries:tess-two:compileReleaseJavaWithJavac UP-TO-DATE
:libraries:tess-two:processReleaseJavaRes UP-TO-DATE
:libraries:tess-two:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
:libraries:tess-two:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
:libraries:tess-two:mergeReleaseJniLibFolders UP-TO-DATE
:libraries:tess-two:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
:libraries:tess-two:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
:libraries:tess-two:bundleRelease UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72311Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2311Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72311Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42311Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidAnswers136Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidBeta114Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlytics255Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlyticsCore238Library UP-TO-DATE
:app:prepareComCrashlyticsSdkAndroidCrashlyticsNdk112Library UP-TO-DATE
:app:prepareComProlificinteractiveMaterialCalendarview070Library UP-TO-DATE
:app:prepareContactManagment1512LibrariesTessTwoUnspecifiedLibrary UP-TO-DATE
:app:prepareIoFabricSdkAndroidFabric1310Library 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
:app:processDebugManifest UP-TO-DATE
:app:fabricGenerateResourcesDebug
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugResources
:app:generateDebugSources
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithDexForDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
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\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 38.882 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

从我在各种论坛上看到的问题来看,与此相关的问题似乎是由“build.gradle”文件中的冲突引起的,主要是在依赖项下。

我在下面添加了我的应用“build.gradle”文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'io.fabric'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.example.l33902.contactmanagment1512"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    useLibrary 'org.apache.http.legacy'

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.prolificinteractive:material-calendarview:0.7.0'

    compile files('libs/json_simple-1.1.jar')
    compile files('libs/jtar-1.1.jar')
    compile files('libs/microsoft-translator-java-api-0.6-mod.jar')
    compile project(':libraries:tess-two')

    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.2@aar') {
        transitive = true;
    }
    crashlytics {
        enableNdk true
        androidNdkOut 'src/main/obj'
        androidNdkLibsOut 'src/main/libs'
    }


}

crashlytics {
    enableNdk true
    androidNdkOut 'src/main/obj'
    androidNdkLibsOut 'src/main/libs'
}

我不确定它出了什么问题,如果有任何建议,请指出我正确的方向。在此先感谢!!〜

2 个答案:

答案 0 :(得分:4)

我以前遇到过这个问题。您应该只包含您实际使用的库。

尝试清理您的项目。从build.gradle中的依赖项中删除一些未使用的库和方法

或者您可以尝试通过以下方式启用multidex支持:

defaultConfig {        
    multiDexEnabled true
}

希望这有帮助!

答案 1 :(得分:2)

从错误记录消息中,似乎在链接您的Java库时发生了问题。你能用像' -i'这样的选项建立项目吗?然后我们可以获得更多信息来查找哪个库已损坏。