java - 尝试连接到 firebase 时 list 合并失败

标签 java android firebase kotlin android-gradle-plugin

我正在尝试将我的应用程序与 firebase 连接,因此我添加了 类路径、实现和“应用插件”到我的 graddle 文件 enter image description here

但是当我尝试运行应用程序时,会发生此错误:

list 合并失败:来自 [com.android.support:support-compat:28.0.0] 的属性 application@appComponentFactory value=(android.sustrong textpport.v4.app.CoreComponentFactory) AndroidManifest.xml:22:18-91 也存在于 [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory) 中。 建议:将 'tools:replace="android:appComponentFactory"' 添加到 AndroidManifest.xml:5:5-24:19 的元素中进行覆盖。

问题是当我添加时

tools:replace="android:appComponentFactory"

在建议中,出现了更多错误。 我该如何解决这个问题?

这是我的 gradle 文件。模块:

    apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "lt.tetro.testapp"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.firebase:firebase-core:17.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'

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

项目:

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

buildscript {
    ext.kotlin_version = '1.3.10'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

最佳答案

firebase-core:17.0.0 包含在 AndroidX 中,因此请更新您的应用以使用 Jetpack (AndroidX)。

您可以查看以下链接中的说明:

https://developer.android.com/jetpack/androidx/migrate

with Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

关于java - 尝试连接到 firebase 时 list 合并失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57172335/

相关文章:

node.js - 是否可以在本地测试 Firebase 触发器?

javascript - Firebase登录成功后如何链接到下一页?

ios - 在 Swift Firebase Analytics 中使用未解析的标识符 'AnalyticsEventScreenView'

java - Intellij IDEA : Impossible to commit files: 'utf8' codec can't decode byte 0xcc in position 9

android - 在android market上传新版本的应用程序后是否可以恢复到以前的版本?

android - SetTexture 和 Sprites 没有按预期工作! (LibGDX)

android - 子项目模块无法解析它自己的依赖

java - 如何从 Eclipse 导出 Java OpenGL (JOGL)?

java - 如何从浏览器获取当前URL

java - Neo4j 原生 Java : Creating a new database in memory rather than hard disk