【问题标题】:Android fail to build when add Firebase Analytics添加 Firebase Analytics 时 Android 无法构建
【发布时间】:2020-10-27 21:17:17
【问题描述】:

我正在尝试使用此build.gradlefirebase-analytics:17.4.4 添加到我的项目中:

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

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "*************"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.+'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:design:28.+'
    implementation 'com.android.support:support-v4:28.+'
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation("com.squareup.okhttp3:okhttp:4.7.2")
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.github.javadev:underscore:1.55'

    implementation 'com.google.firebase:firebase-analytics:17.4.4'

    implementation 'com.github.bumptech.glide:glide:4.9.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}

当我尝试构建项目时出现此错误的问题:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:9:5-26:19 to override.

【问题讨论】:

    标签: java android firebase kotlin firebase-analytics


    【解决方案1】:

    Firebase Analytics 17.0.0+ 使用 AndroidX。所以你必须migrate your app to AndroidX 才能使用它。

    参考:https://firebase.google.com/support/release-notes/android#2019-06-17

    【讨论】:

      猜你喜欢
      • 2019-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-02
      • 2020-06-05
      相关资源
      最近更新 更多