【问题标题】:gradle finished with non-zero exit value 3gradle 以非零退出值 3 完成
【发布时间】:2015-10-14 19:36:32
【问题描述】:

我的项目包含 3 个库:calendar_cmccWheel_libraryyellowPage_lib

我可以完美构建项目,但是gradle在运行的时候会报错。错误如下:

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

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/jim/tools/jdk1.8.0_45/bin/java'' 用非完成零退出值 3

gradle 文件列表:

应用的 build.gradle:

apply plugin: 'com.android.application'

        android {

            compileSdkVersion 21
            buildToolsVersion '21.1.2'

            defaultConfig {
                applicationId "cn.com.geartech.app"
                minSdkVersion 17
                targetSdkVersion 19
                versionCode 100 //from 20 to 21
                //cmcc0000522 is 26
                //0608 is
                // 27
                //0615 is 27
                //0616 is 27
                //1.2.20 36
                versionName "1.2.26.10"
                multiDexEnabled = true
            }
            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                }

                debug {
                    signingConfig signingConfigs.deb
                }
            }
            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/ASL2.0'
            }
            sourceSets {
                main {
                    jniLibs.srcDir 'src/main/libs'
                }
            }
            compileOptions {
                sourceCompatibility JavaVersion.VERSION_1_7
                targetCompatibility JavaVersion.VERSION_1_7
            }
        }

        dependencies {
            compile 'com.android.support:support-v4:20.+'
            compile 'com.android.support:recyclerview-v7:21.0.0'
            compile 'com.daimajia.swipelayout:library:1.2.0@aar'
            compile 'jp.wasabeef:recyclerview-animators:1.0.3@aar'
            compile fileTree(include: ['*.jar'], dir: 'libs')
            compile files('src/main/libs/commons-io-2.4.jar')
            compile files('src/main/libs/httpmime-4.1.1.jar')
            compile files('src/main/libs/pinyin4j-2.5.0.jar')
            compile files('src/main/libs/universal-image-loader-1.9.3-with-sources.jar')
            compile files('src/main/libs/zxing.jar')
            compile 'com.sothree.slidinguppanel:library:3.0.0'
            compile files('src/main/libs/cmcc-sso-sdk.jar')
            compile files('src/main/libs/cmcc-sso.jar')
            compile files('src/main/libs/cmcc_enc.jar')
            compile files('src/main/libs/AOE_20140617_001.jar')
            compile files('src/main/libs/sync_sdk_ydyjyxgh_20150304.jar')
            compile files('src/main/libs/fastjson-1.2.5.jar')
            compile project(':yellowPage_lib')
            compile project(':Wheel_library')
            compile project(':calendar_cmcc')
            compile files('src/main/libs/pinyin4j.jar')
            compile files('src/main/libs/gcordSDK.jar')
        }
calendar_cmcc

build.gradle:

apply plugin: 'com.android.library'

    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.2"

        defaultConfig {
            minSdkVersion 17
            targetSdkVersion 17
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        productFlavors {
        }
        lintOptions {
            abortOnError false
        }
        packagingOptions {
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
        }
    }
    configurations.all {
        exclude module: 'commons-logging'
    }
    dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'commons-lang:commons-lang:2.6'
        compile 'commons-io:commons-io:2.4'
        compile 'org.projectlombok:lombok:1.14.8'
        compile 'org.mnode.ical4j:ical4j:1.0.6'
        compile('com.googlecode.ez-vcard:ez-vcard:0.9.6') {
            exclude group: 'org.jsoup', module: 'jsoup'
            exclude group: 'org.freemarker', module: 'freemarker'
            exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
        }
        compile 'dnsjava:dnsjava:2.1.6'
        compile files('lib/httpclient-android-4.3.5.2-davdroid1.jar')
        compile('org.simpleframework:simple-xml:2.7.1') {
            exclude group: 'stax', module: 'stax-api'
            exclude group: 'xpp3', module: 'xpp3'
        }
        compile 'com.android.support:appcompat-v7:18.0.0'
        compile files('libs/android-common-chips.jar')
        compile files('libs/android-common.jar')
        compile files('libs/calendar-common.jar')
    }
Wheel_library

build.gradle:

    apply plugin: 'com.android.library'
    android {
        compileSdkVersion 21
        buildToolsVersion '21.1.2'

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

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

build.gradle:

        apply plugin: 'com.android.library'

        android {
            compileSdkVersion 21
            buildToolsVersion '21.1.2'

            defaultConfig {
                minSdkVersion 8
                targetSdkVersion 19
            }

            buildTypes {
                release {
                    minifyEnabled false
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
                }
            }
        }

        dependencies {
            compile 'com.android.support:support-v4:19.+'
            compile files('libs/BaiduLBS_Android.jar')
            compile files('libs/YellowPage_SDK.jar')
        }

现在,我只知道错误是由 calendar_cmcc's build.gradle 文件引起的。当我将 calendar_cmcc's 构建中的“编译”更改为“提供”依赖项时.gradle ,它运行良好。

dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'commons-lang:commons-lang:2.6'
        compile 'commons-io:commons-io:2.4'
        compile 'org.projectlombok:lombok:1.14.8'
        compile 'org.mnode.ical4j:ical4j:1.0.6'
        compile('com.googlecode.ez-vcard:ez-vcard:0.9.6') {
            exclude group: 'org.jsoup', module: 'jsoup'
            exclude group: 'org.freemarker', module: 'freemarker'
            exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
        }
        compile 'dnsjava:dnsjava:2.1.6'
        compile files('lib/httpclient-android-4.3.5.2-davdroid1.jar')
        compile('org.simpleframework:simple-xml:2.7.1') {
            exclude group: 'stax', module: 'stax-api'
            exclude group: 'xpp3', module: 'xpp3'
        }
        compile 'com.android.support:appcompat-v7:18.0.0'
        compile files('libs/android-common-chips.jar')
        compile files('libs/android-common.jar')
        compile files('libs/calendar-common.jar')
    }

改为

dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        compile 'commons-lang:commons-lang:2.6'
        compile 'commons-io:commons-io:2.4'
        provided 'org.projectlombok:lombok:1.14.8'
        provided 'org.mnode.ical4j:ical4j:1.0.6'
        provided ('com.googlecode.ez-vcard:ez-vcard:0.9.6') {
            exclude group: 'org.jsoup', module: 'jsoup'
            exclude group: 'org.freemarker', module: 'freemarker'
            exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
        }
        compile 'dnsjava:dnsjava:2.1.6'
        compile files('lib/httpclient-android-4.3.5.2-davdroid1.jar')
        compile('org.simpleframework:simple-xml:2.7.1') {
            exclude group: 'stax', module: 'stax-api'
            exclude group: 'xpp3', module: 'xpp3'
        }
        compile 'com.android.support:appcompat-v7:18.0.0'
        compile files('libs/android-common-chips.jar')
        compile files('libs/android-common.jar')
        compile files('libs/calendar-common.jar')
    }

但它会导致另一个错误:

07-24 15:54:41.991   32166-1373/cn.com.geartech.app E/dalvikvm﹕ Could not find class 'net.fortuna.ical4j.model.DefaultTimeZoneRegistryFactory', referenced from method at.bitfire.davdroid.resource.Event.<clinit>
    07-24 15:54:42.001   32166-1373/cn.com.geartech.app E/dalvikvm﹕ Could not find class 'net.fortuna.ical4j.data.CalendarBuilder', referenced from method at.bitfire.davdroid.resource.Event.TimezoneDefToTzId
    07-24 15:54:42.021   32166-1373/cn.com.geartech.app E/dalvikvm﹕ Could not find class 'net.fortuna.ical4j.util.UidGenerator', referenced from method at.bitfire.davdroid.resource.Event.generateUID
    07-24 15:54:42.061   32166-1373/cn.com.geartech.app E/dalvikvm﹕ Could not find class 'net.fortuna.ical4j.data.CalendarBuilder', referenced from method at.bitfire.davdroid.resource.Event.parseEntity

在gradle build的时候好像org.mnode.ical4j不能打包在apk里面。

我已经在 stackoverflow 上搜索了很多天的答案,但它无法正常工作。 那么,我该怎么办?请帮忙!谢谢!

【问题讨论】:

  • 我自己解决了。当你的项目包含太多文件时,Android studio会抛出一个问题:finished with non-zero exit value 3。这是Android studio的限制,但不是intellij想法。所以,只需将:dexOptions { javaMaxHeapSize "4g" } 添加到您的 app.gradle 文件中,它就可以正常工作了。可能,在解决了我们上面讨论的问题后。它会导致另一个问题:找不到 ***。 jar或者***.class文件。应该是65k方法的问题,看这个链接:developer.android.com/tools/building/multidex.html

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


【解决方案1】:

我在这里重新发布 jim.zhang 的答案: (自从第一次看这个问题,就错过了zhang的评论)

在 build.gradle 文件中添加下面的配置。

dexOptions {
    javaMaxHeapSize "4g"
}

【讨论】:

  • 谢谢!并且可能,会导致另一个问题:找不到 ***.jar 或 ***.class 文件。应该是 65k 方法的问题,所以你应该看这个链接:developer.android.com/tools/building/multidex .html
  • 我做了同样的尝试添加: android { dexOptions { javaMaxHeapSize "4g" } } 到 build.gradle。谢谢@Anh-Tuan Mai
猜你喜欢
  • 2016-01-19
  • 1970-01-01
  • 2017-11-13
  • 2015-06-27
  • 1970-01-01
  • 2016-09-28
  • 1970-01-01
  • 2015-05-28
相关资源
最近更新 更多