1

我最近在使用 Retrolambda 时尝试在我的应用程序中调试时遇到了很多问题,因为我想在我的 Gradle 中包含 Jack 以进行调试。

jackOptions {
   enabled true
}

因此,我一直在经历这个错误,但我仍然没有找到解决它的方法。

Jackson : NoSuchMethodError for com.google.common.base.Preconditions.checkState

我检查了不同的帖子以寻找解决方案:

Android Studio:Gradle - 构建失败 - 任务“:dexDebug”执行失败

使用 jack 时,Lambda 表达式在 Android 中因 IncompatibleClassChangeError 而崩溃

建议为运行 jack 的 Gradle 守护进程使用更大的堆

但是没有一个解决方案可以解决我的问题。现在我的 Gradle 看起来像:

buildscript {
    ext {
        use_jack = true
        dagger_version = "2.8"
        firebase_version = "9.6.1"
        rx_version = "2.0.3"
        rx_firebase_version = "1.0.0"
        rx_android_version = "2.0.1"
        gson_version = "2.8.0"
        butterkinfe_version = "8.4.0"
        support_version = "25.0.0"
        target_sdk_version = 24
    }
}


apply plugin: 'com.android.application'
if (!use_jack) { //Backport to apt / RetroLambda
    apply plugin: 'me.tatarka.retrolambda'
    apply plugin: 'com.neenbedankt.android-apt'
}
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.myaplicattion"
        minSdkVersion 15
        targetSdkVersion project.properties.target_sdk_version
        versionCode 1
        versionName "0.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        jackOptions {
            enabled use_jack
        }
    }
    buildTypes {
        debug {
            minifyEnabled false
            testCoverageEnabled = true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
}

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

    //Support
    compile "com.android.support:appcompat-v7:$support_version"
    compile "com.android.support:design:$support_version"

    //Util
    compile 'com.intellij:annotations:12.0'
    compile 'com.jakewharton.timber:timber:4.3.1'
    compile "com.jakewharton:butterknife:$butterkinfe_version"
    if (use_jack) annotationProcessor "com.jakewharton:butterknife-compiler:$butterkinfe_version"
    else apt "com.jakewharton:butterknife-compiler:$butterkinfe_version"
    compile 'com.github.mukeshsolanki:country-picker-android:1.1.6'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
    //Glide
    compile 'com.github.bumptech.glide:glide:3.7.0'

    //Firebase
//    compile "com.firebaseui:firebase-ui-database:0.4.0"
    compile "com.google.firebase:firebase-storage:$firebase_version"
    compile "com.google.firebase:firebase-messaging:$firebase_version"
    compile "com.google.firebase:firebase-common:$firebase_version"
    compile "com.google.firebase:firebase-auth:$firebase_version"
    compile "com.google.firebase:firebase-core:$firebase_version"
    compile "com.google.firebase:firebase-database:$firebase_version"
    compile "com.google.firebase:firebase-crash:$firebase_version"
    compile "com.github.frangsierra:rx2firebase:$rx_firebase_version"

    //GSON
    compile "com.google.code.gson:gson:$gson_version"
    //Facebook
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'

    //Dagger
    compile "com.google.dagger:dagger:$dagger_version"
    if (use_jack) annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
    else apt "com.google.dagger:dagger-compiler:$dagger_version"

    //Rx
    compile "io.reactivex.rxjava2:rxjava:$rx_version"
    compile "io.reactivex.rxjava2:rxandroid:$rx_android_version"

    //Test
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    compile 'com.android.support.test:runner:0.5'
}

apply plugin: 'com.google.gms.google-services'

我的appgradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'me.tatarka:gradle-retrolambda:3.2.5'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        mavenLocal()
        maven { url "https://jitpack.io" }
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
4

0 回答 0