Android with Gradle(Java 以非零退出值 2 结束) [英] Android with Gradle (Java finished with non-zero exit value 2)

查看:27
本文介绍了Android with Gradle(Java 以非零退出值 2 结束)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的 .gradle 文件:

This is my .gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

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

    packagingOptions {
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'

    compile 'com.mcxiaoke.volley:library:1.0.15'
    compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.17'
}

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

When I try to run my Android app, I get the next error:

错误:任务:app:dexDebug"的执行失败.

Error:Execution failed for task ':app:dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' 以非完成-零退出值 2

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2

当我将 jackson 库添加到 gradle 文件时出现此错误.谷歌搜索一段时间,我发现jackson库与android应用程序兼容,并且比gson的其他库更快.

I get this error when I add to gradle file the jackson library. Googling some time, I've found that jackson library is compatible with android apps, and It's faster than other libraries as gson.

我该如何解决?我是 Android 初学者.

How I can solve it? I'm an Android beginner.

推荐答案

我认为您应该更改您的 java JDK 更改 jvm v8 为 jdk7.此链接可以帮助您:是否可以使用 Java 8 进行 Android 开发?

I think you should change your java JDK change jvm v8 for jdk7. This link can help you: Is it possible to use Java 8 for Android development?

其他可能的问题是它的依赖错误,在构建之前清理 gradle.并为此更改您的 jackson 库:

Other possible issue its dependency error, clean gradle before build. And change your jackson library for this:

compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+'
compile 'com.fasterxml.jackson.core:jackson-core:2.2.+'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.+'

这篇关于Android with Gradle(Java 以非零退出值 2 结束)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆