首页 > 解决方案 > (它没有 rc01)清单合并失败:属性 application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory)

问题描述

它说清单合并错误,尽管我的清单实际上是正确的

这是我的应用程序模块 gradle 依赖文件

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
    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:cardview-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
    implementation 'com.firebaseui:firebase-ui-database:0.4.1'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
}
apply plugin: 'com.google.gms.google-services'

这是错误

清单合并失败:来自 [com.android.support:support-compat:28.0.0-alpha3] AndroidManifest.xml:22:18-91 的属性 application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) 也是存在于 [androidx.core:core:1.0.0-alpha3] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory)。建议:添加 'tools:replace="android:appComponentFactory"'

标签: androidandroid-studio

解决方案


问题与 AndroidX 库有关。将您的支持库迁移到 AndroidX。在 AndroidStudio 中,您可以使用Refactor > Migrate to AndroidX菜单手动执行此操作。使用 VCS(例如 git)跟踪更改以查看会发生什么。

您也可以通过将 gradle 依赖项更改为:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //noinspection GradleCompatible
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-database:18.0.0'
    implementation 'com.firebaseui:firebase-ui-database:0.4.1'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
}
apply plugin: 'com.google.gms.google-services'

然后,找到所有旧的依赖项导入和新的依赖项。


将这些标志放入您的gradle.properties可以解决一些相关问题:

android.enableJetifier=true
android.useAndroidX=true

推荐阅读