Firebase 与 appcompat 不兼容

Firebase incompatible with appcompat

我刚刚更新了 gradle 依赖项,现在出现编译错误,我不知道如何处理。

这是我的 gradle 依赖项:

dependencies {
    implementation "android.arch.work:work-runtime:1.0.1"
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.google.firebase:firebase-core:17.0.1'
    implementation 'com.google.firebase:firebase-messaging:19.0.1'
    implementation 'com.google.android.gms:play-services-plus:17.0.0'
    implementation 'com.google.android.gms:play-services-places:17.0.0'


    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.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'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
    implementation 'com.android.support:cardview-v7:28.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

好像Firebase和play-service与appcompat不兼容,但我不知道如何处理。

我得到的错误是:

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

按照建议将 'tools:replace="android:appComponentFactory" 添加到清单中会使事情变得更糟。

Appcompat 在工具提示中显示此消息: Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='viewpager', myVersion='28.0.0', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.interpolator', myArtifactId='interpolator', myVersion='1.0.0', myPacking='aar', myClassifier='null'} incompatible dependencies less... (⌘F1) Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).

我需要有关如何修复 gradle 依赖项的建议。

您必须在 gradle.properties 文件中添加两行:

android.useAndroidX=true
android.enableJetifier=true

这两行解决了 google 的文件与其他第三方依赖项之间存在冲突的依赖项。

尝试升级所有当前依赖项。