【问题标题】:Gradle (Java finished with non-zero exit value 2) [duplicate]Gradle(Java以非零退出值2完成)[重复]
【发布时间】:2016-09-28 03:32:39
【问题描述】:
  apply plugin: 'com.android.application'

    android {


      compileSdkVersion 23
buildToolsVersion "23.0.0"

defaultConfig {

        minSdkVersion 13
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"

    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_6
        targetCompatibility JavaVersion.VERSION_1_6
    }


    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/BCKEY.DSA'
        exclude 'AUTHORS'
    }

}

    dependencies {
provided fileTree(include: ['*.jar'], dir: 'libs')

compile 'com.firebase:firebase-client-android:2.3.1+'

compile 'com.google.firebase:firebase-crash:9.0.0'

compile 'com.google.android.gms:play-services:9.0.0'

compile 'com.jakewharton:butterknife:8.0.1'

}

【问题讨论】:

  • 你的 lib 文件夹中有 jars 吗?
  • 你能再解释一下吗?

标签: java android gradle


【解决方案1】:

这个问题可以通过清理项目,从 build.gradle 中的依赖中删除一些未使用的库和方法,或者通过添加 multidex 支持来解决。

    defaultConfig {        
        // Enabling multidex support.
        multiDexEnabled true
        minSdkVersion 13
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

【讨论】:

  • 这对我有效
  • @user6399873..亲爱的我很高兴...快乐编码...:)
【解决方案2】:

这可能是由于以下原因:

  1. 项目中的一个 jar 文件使用的是旧版本的 谷歌播放服务。
  2. 在 defaultconfig 中使用 multiDexEnabled true
  3. 具体说明您在依赖项中添加的类。喜欢

    编译'com.google.android.gms:play-services-maps:8.4.0'

    不像compile 'com.google.android.gms:play-services:+'

【讨论】:

    猜你喜欢
    • 2015-06-27
    • 2016-01-19
    • 2016-01-21
    • 1970-01-01
    • 1970-01-01
    • 2015-10-14
    • 1970-01-01
    • 1970-01-01
    • 2015-09-26
    相关资源
    最近更新 更多