【问题标题】:Realm and jackOptions Java finished with non-zero exit value 1 - Android GradleRealm 和 jackOptions Java 以非零退出值 1 完成 - Android Gradle
【发布时间】:2016-09-09 00:05:40
【问题描述】:

升级到 Android 设计工具 24 后,我的项目将不再运行。它构建良好,没有任何错误,但是当我运行它时出现错误:

错误:Gradle:任务 ':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_102\bin\java.exe'' 以非零退出值 1 结束

这是我的 build.gradle 文件:

apply plugin: 'com.android.application'

apply plugin: 'realm-android'

android {

compileSdkVersion 24
buildToolsVersion "24.0.2"

defaultConfig {
    applicationId "com.example.don.mstp"
    minSdkVersion 15
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    // Enabling multidex support.
    multiDexEnabled true
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}


buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
dexOptions {
    incremental true
    javaMaxHeapSize "4g"
    preDexLibraries = false
}


}

dependencies {

compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.github.Lukle:ClickableAreasImages:v0.1'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.github.javiersantos:MaterialstyledDialogs:1.3'
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
compile 'com.ramotion.foldingcell:folding-cell:1.0.1'
compile 'com.github.brnunes:swipeablerecyclerview:1.0.2'
compile 'com.github.gabrielemariotti.recyclerview:recyclerview-animators:0.3.0-SNAPSHOT@aar'
compile 'com.tiancaicc.springfloatingactionmenu:library:0.0.2'
compile 'com.daimajia.numberprogressbar:library:1.2@aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.daprlabs.aaron:cardstack:0.3.0'
compile 'com.txusballesteros:FitChart:1.0'
compile 'com.github.SilenceDut:ExpandableLayout:v1.0.1'

}

【问题讨论】:

  • 你真的需要 multidex "compile 'com.android.support:multidex:1.0.1'" 我非常怀疑它,但你应该看到你拉入你的应用程序的依赖项,很可能 gradle 失败因为您有大量依赖项,其中很可能包括其他依赖项,我相信您有重复项。在 Android Studio 中运行 ./gradlew app:dependencies 从终端检查
  • 根据android文档:developer.android.com/studio/build/multidex.html,我需要添加“编译'com.android.support:multidex:1.0.0',更进一步并添加最新的。我是使用 Intellij,似乎没有“gradle 控制台”。我使用了很多依赖项,我的猜测是我可能已经超过 65K 方法。感谢您的及时回答。
  • 仅在构建调试时或在构建发布时是否收到错误?另外,为什么你关闭了proguardminifyEnabled false,应该为发布和调试启用。
  • 我无法具体说明您的问题,但我想告诉您不要使用 Google 的支持库 x.x.0。它几乎总是会破坏构建、导致崩溃或给出不稳定的结果。我们总是从 x.x.1 版本开始申请。这就是我们从历史中学到的。

标签: java android intellij-idea android-gradle-plugin build.gradle


【解决方案1】:

我终于让我的项目运行起来了,方法如下:

显然,目前无法将 Jack 编译器与 Realm 一起使用,因为 Jack 不支持字节码操作(Javassist / Transform API)。话虽如此,但我们现在可以使用“retrolambda”并删除 jackOptions。

在你的 build.gradle 中

apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
}

在项目主gradle添加类路径:

 dependencies {
        classpath 'io.realm:realm-gradle-plugin:0.88.3'
        classpath 'me.tatarka:gradle-retrolambda:3.2.5'

    }

这让我的项目再次运行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-27
    • 2017-11-13
    • 1970-01-01
    • 2015-07-09
    • 2015-10-14
    • 2016-01-19
    • 2016-09-28
    相关资源
    最近更新 更多