android - 这是什么意思?添加 'tools:replace="安卓 :appComponentFactory"' to <application> element

标签 android androidx

我正在尝试在我的 Android 应用程序中使用 firebase。

这是我的 Build.gradle 文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.ecommerce5"
        minSdkVersion 27
        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.0.0-rc02'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'

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

    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'
}

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

当我删除以下代码行并运行应用程序时,应用程序运行正常。

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

但是当我添加以上行并运行代码时,应用程序显示以下错误:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0-rc02] 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:5:5-19:19 to override.

这是什么意思?

Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-24:19 to override.

最佳答案

转换/升级您的项目以使用 androidX。你有支持和 androidX 的混合体。

我认为在 Androix Studio 中有一个菜单项:Edit -> Convert to AndroidX

要么这个,要么你尝试错误消息中的建议:

 Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.

关于android - 这是什么意思?添加 'tools:replace="安卓 :appComponentFactory"' to <application> element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59176596/

相关文章:

Android 无法使用 for 循环从 Parse.com 数据库获取用户数据

android - 如何根据 Kotlin 中的进度条进度更新 textview 值

database - Room @Query 注释字符串字段不带引号

androidx.paging.PagedListAdapter' 已弃用

android - 如何从 Android Espresso 测试的 google Firebase 获取代码覆盖率报告

java - 带有淡入淡出 ImageView 动画的启动画面

android - 无法从模拟器传输大于 2 MB 的文件

android - 在 Android 10+ 上用什么代替已弃用的 android.preference 库?

java - androidx BottomNavigationView 未显示

Android 在将 androidx 生物识别更新为 1.0.0-alpha04 后崩溃