集成 Firebase crashlytics 和 Fabric 依赖项时重复资源

Duplicate resources when integrating Firebase crashlytics and Fabric dependencies

我有以下 gradle(:app) 文件 -

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'io.fabric'


android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.twoverte"
        minSdkVersion 23
        targetSdkVersion 29
        versionCode 8
        versionName "1.0.7"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        kotlinOptions {
            jvmTarget = JavaVersion.VERSION_1_8.toString()
        }
    }

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

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    //Room components
    implementation 'androidx.room:room-runtime:2.2.5'
    implementation 'androidx.room:room-ktx:2.2.5'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.4'
    kapt 'androidx.room:room-compiler:2.2.5'
    kapt "android.arch.persistence.room:compiler:2.2.5"

    //Lifecycle components
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-common-java8:2.2.0'

    //Kotlin
    implementation 'org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.72'
    implementation "androidx.core:core-ktx:1.2.0"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.0-alpha02'

    //Google
    implementation 'com.google.android.gms:play-services-auth:18.0.0'
    implementation 'com.google.android.gms:play-services-auth-api-phone:17.4.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'

    //Networking
    implementation 'com.smartarmenia:dotnetcoresignalrclientjava:1.14'
    implementation 'com.microsoft.signalr:signalr:5.0.0-preview.2.20167.3'
    implementation 'com.squareup.retrofit2:retrofit:2.8.1'

    //RxJava + RxAndroid
    implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
    implementation 'io.reactivex.rxjava3:rxjava:3.0.0'

    //Gson
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.squareup.retrofit2:converter-gson:2.8.1'

    //Firebase
    implementation 'com.google.firebase:firebase-messaging:20.1.6'

    //Firebase Crashlytics
    implementation 'com.google.firebase:firebase-analytics:17.4.0'
    implementation 'com.google.firebase:firebase-crashlytics:17.0.0'
    implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
        transitive = true
    }

    //Permissions
    implementation 'com.karumi:dexter:6.1.0'

    //UI
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.android.support:multidex:1.0.3'
    implementation "androidx.viewpager2:viewpager2:1.0.0"
    implementation 'com.google.android.material:material:1.1.0'
    implementation "androidx.cardview:cardview:1.0.0"
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    implementation 'com.makeramen:roundedimageview:2.3.0'
    implementation 'com.github.zhukic:sectioned-recyclerview:1.2.3'
    implementation "androidx.exifinterface:exifinterface:1.2.0"
    implementation 'id.zelory:compressor:3.0.0'
    implementation 'commons-io:commons-io:20030203.000550'
    implementation 'com.libRG:customtextview:2.2'

    //Compression
    implementation 'id.zelory:compressor:3.0.0'

    //Util
    implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:3.0.0-RC2'
}

和以下 gralde(:project) 文件 -

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

buildscript {
    ext.kotlin_version = '1.3.72'
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'

        //Firebase Crashlytics
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0'
        classpath 'io.fabric.tools:gradle:1.28.0'

    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }

    }
}

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

出于某种原因,它给了我一个 Duplicate resource 错误 -

我试图删除那里提到的文件,但没有帮助,因为它们被重新添加并且错误一次又一次地出现。

我不明白冲突在哪里,但两个图书馆似乎在一起并不愉快。

试图在此处检查解决方案,但无济于事。

我可能错了,但在我看来问题是您同时使用 fabric 和 firebase,据我所知不再支持 fabric

” 织物的未来 我们已将 Fabric 的精华集成到 Firebase 中,为您带来一个强大的应用程序开发平台。 Fabric 已弃用,现有用户可以使用到 2020 年 5 月 4 日。新用户应该从 Firebase 开始,以利用我们在那里构建的最新产品和功能。学到更多 “

仅供参考

Fabric 已弃用,并且将在 2020 年 5 月 4 日之前可用 现有 users.Crashlytics 和 Crashlytics Beta 已集成进入 Firebase,具有 Firebase 独有的新功能。

不要

 classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0'
 classpath 'io.fabric.tools:gradle:1.28.0'

// Add the Fabric Crashlytics plugin.
classpath 'io.fabric.tools:gradle:1.31.2'

在您的应用级别 build.gradle,添加 Crashlytics 依赖项:

// (Recommended) Add the Google Analytics dependency.
implementation 'com.google.firebase:firebase-analytics:17.4.0'

// Add the Firebase Crashlytics dependency.
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'

阅读关于 Get started with Firebase Crashlytics 的官方指南。