使用 firebase Crashlytics 时以下任务之间的循环依赖

Circular dependency between the following tasks while using firebase Crashlytics

今天我刚从 fabric crashlytics 迁移到 Firebase crashlytics。

使用 minifyEnabled false 一切正常,但是当我更改 minifyEnabled true 时,我遇到了这个异常:

Circular dependency between the following tasks:
:app:checkManifestChangesDebug
\--- :app:instantRunMainApkResourcesDebug
 \--- :app:transformClassesAndDexWithShrinkResForDebug
      \--- :app:transformDexArchiveWithDexMergerForDebug
           +--- :app:preColdswapDebug
           |    \--- :app:incrementalDebugTasks
           |         +--- :app:transformClassesAndClassesEnhancedWithInstantReloadDexForDebug
           |         |    \--- :app:transformClassesWithInstantRunForDebug
           |         |         \--- :app:checkManifestChangesDebug (*)
           |         \--- :app:transformClassesWithInstantRunForDebug (*)
           \--- :app:transformClassesWithDexBuilderForDebug
                +--- :app:preColdswapDebug (*)
                \--- :app:transformClassesWithInstantRunForDebug (*)

(*) - details omitted (listed previously)

这里是项目级构建gradle

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

buildscript {
ext.butterknife_version = '8.8.1'
ext.supportLibVersion = '28.0.0'
ext.kotlin_version = '1.2.71'
ext.retrofit_version = '2.3.0'
ext.anko_version = '0.10.4'
ext.google_play_service_version = '16.0.0'
ext.firebase_messaging_version = '17.3.4'
repositories {
    maven { url 'https://maven.google.com' }
    jcenter()
    google()

    //for firebase crashlytics
    maven {
        url 'https://maven.fabric.io/public'
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath "com.jakewharton:butterknife-gradle-plugin:$butterknife_version"
    classpath 'com.google.gms:google-services:4.2.0'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files

    classpath 'io.fabric.tools:gradle:1.27.0'
}
}

allprojects {
repositories {
    maven { url 'https://maven.google.com' }
    jcenter()
    maven {
        url "https://github.com/omadahealth/omada-nexus/raw/master/release"
    }
    maven {
        url 'https://maven.fabric.io/public'
    }
    maven { url "https://jitpack.io" }
    mavenCentral()
}
}

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

这是模块构建 gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.mta.mmp"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 18
    versionName "1.2.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
    dexOptions {
        javaMaxHeapSize "4g"
    }
}
buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        buildConfigField 'String', 'FirebaseTopicForPushNotification', "\"PROD_ANDROID_BROADCAST_MMP\""
    }
    dev {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        buildConfigField 'String', 'FirebaseTopicForPushNotification', "\"UAT_ANDROID_BROADCAST_MMP\""
    }
    debug {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        buildConfigField 'String', 'FirebaseTopicForPushNotification', "\"UAT_ANDROID_BROADCAST_MMP\""
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}


repositories {
maven { url "https://jitpack.io" }
}



dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
configurations {
    all*.exclude group: 'com.android.support', module: 'support-v13'
}
testImplementation 'junit:junit:4.12'

//kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation "com.android.support:design:$supportLibVersion"
implementation "com.android.support:recyclerview-v7:$supportLibVersion"
implementation "com.android.support:cardview-v7:$supportLibVersion"
implementation "com.android.support:support-v4:$supportLibVersion"

//retrofit 2
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"

//retrofit http interceptor
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'

//gson converter factory
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation 'com.google.code.gson:gson:2.8.2'

//RxAndroid
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'

//picaso library
implementation 'com.squareup.picasso:picasso:2.5.2'

//form validation library
implementation 'com.mobsandgeeks:android-saripaar:2.0.3'

//font library
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'

//material dialog
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'

//joda time
implementation 'net.danlew:android.joda:2.9.4.3'

//circleimageview
implementation 'de.hdodenhof:circleimageview:2.2.0'

//recyclerview animation
implementation 'jp.wasabeef:recyclerview-animators:2.2.5'

//Butterknife
implementation "com.jakewharton:butterknife:$butterknife_version"
kapt "com.jakewharton:butterknife-compiler:$butterknife_version"

//rx runtime permissions
implementation 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar'

//rx binding
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'

//pinlib
//    compile project(':pinLib')

//circle indicator
implementation 'me.relex:circleindicator:1.2.2@aar'

//AndroidSlidingUpPanel
implementation 'com.sothree.slidinguppanel:library:3.3.1'

//toasty
implementation 'com.github.GrenderG:Toasty:1.2.5'

//for google map
implementation "com.google.android.gms:play-services-maps:$google_play_service_version"

//for location
implementation "com.google.android.gms:play-services-location:$google_play_service_version"

//Transitions Everywhere
implementation "com.andkulikov:transitionseverywhere:1.7.4"

//Android-Iconics
implementation "com.mikepenz:iconics-core:2.8.8@aar"
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation 'com.mikepenz:google-material-typeface:3.0.1.1.original@aar'

//Multidex
implementation 'com.android.support:multidex:1.0.3'

//for recyclerview swipe
implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'

//RippleView
implementation 'com.github.traex.rippleeffect:ripple:1.3.1-OG'

//TypefaceView
implementation 'com.github.omadahealth.typefaceview:typefaceview:1.5.0@aar'

//firebase Cloud Messaging
implementation "com.google.firebase:firebase-messaging:$firebase_messaging_version"
implementation 'com.google.firebase:firebase-core:16.0.6'

//qr scanner
implementation 'me.dm7.barcodescanner:zxing:1.9.4'

//MaterialDateTimePicker
implementation 'com.wdullaer:materialdatetimepicker:3.6.0'

implementation 'com.github.drawers:SpinnerDatePicker:1.0.6'

//anko
implementation "org.jetbrains.anko:anko:$anko_version"

// Anko Commons
implementation "org.jetbrains.anko:anko-commons:$anko_version"

//google maps utils
implementation 'com.google.maps.android:android-maps-utils:0.5+'

//crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.7'

//kotpref
implementation "com.chibatching.kotpref:kotpref:2.4.0"
implementation "com.chibatching.kotpref:initializer:2.4.0" // optional
implementation "com.chibatching.kotpref:enum-support:2.4.0" // optional
implementation "com.chibatching.kotpref:gson-support:2.4.0" // optional

//rootbear
implementation 'com.scottyab:rootbeer-lib:0.0.6'

//autofittextview
implementation 'me.grantland:autofittextview:0.2.+'

//libphonenumber
implementation 'io.michaelrocks:libphonenumber-android:8.9.0'

//ksfmememory lib
//implementation(name: 'ksfmemoryidlib-release', ext: 'aar')
implementation 'org.apache.commons:commons-compress:1.15'

//rounded imageview
implementation 'com.makeramen:roundedimageview:2.3.0'

//Scaling layout
implementation 'com.github.iammert:ScalingLayout:1.2.1'

//Crisp MMP
implementation 'im.crisp:crisp-sdk:0.1.8'

//slider from daimajia
implementation 'com.daimajia.slider:library:1.1.5@aar'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.8.0'

implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'

//Camera view
implementation 'com.otaliastudios:cameraview:1.5.1'

//Picasso2-okhttp3-downloader
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'

//Restring 1.0
implementation 'com.ice.restring:restring:1.0.0'
}

repositories {
flatDir {
    dirs 'libs'
}
}

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

crashlytics 的混淆器是

#PROGUARD RULE FOR FIREBASE CRASHLYTICS
#----------------------------------------------------------------------
# https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception

# To let Crashlytics automatically upload the ProGuard or DexGuard mapping 
file, remove this line from the config file
# -printmapping mapping.txt

-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**

根据我们的评论讨论,确保禁用 Instant 运行 以立即修复解决方案!