Java Android studio firebase集成出现错误

Java Android studio firebase集成出现错误,java,android,firebase,android-studio,firebase-authentication,Java,Android,Firebase,Android Studio,Firebase Authentication,我是android studio的新手,我正在尝试学习firebase并在我的虚拟应用程序中实现google登录 我继续遵循谷歌的文档,在build.gradle文件中包含了某些行 在project/gradle中,我添加了 classpath'com.google.gms:googleservices:4.3.3' 在app/gradle中,我检查了apply插件:“com.android.application”和 应用插件:“com.google.gms.google服务” 因为它已经在那

我是android studio的新手,我正在尝试学习firebase并在我的虚拟应用程序中实现google登录

我继续遵循谷歌的文档,在build.gradle文件中包含了某些行

在project/gradle中,我添加了
classpath'com.google.gms:googleservices:4.3.3'

在app/gradle中,我检查了
apply插件:“com.android.application”
应用插件:“com.google.gms.google服务”

因为它已经在那里了,我补充说:
implementation'com.google.firebase:firebase分析:17.2.2'

我同步了我的项目,当我尝试运行应用程序时,出现以下错误:

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:5:5-19:19 to override.
包梯度文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.MyName.TestApp"
        minSdkVersion 23
        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'
    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.google.firebase:firebase-analytics:17.2.3'
}

apply plugin: 'com.google.gms.google-services'
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.3.3'


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

如果您想使用Analytics 17.2.2版,则需要升级androidx。从文档中:

除非您在应用程序中进行以下更改,否则更新的库将无法工作:

  • 升级com.android.tools.build:gradle至v3.2.1或更高版本
  • 将CompileSDK版本升级到28或更高版本
  • 更新应用程序以使用Jetpack(AndroidX);按照中的说明操作

  • 如果要使用Analytics 17.2.2版,则需要升级androidx。从文档中:

    除非您在应用程序中进行以下更改,否则更新的库将无法工作:

  • 升级com.android.tools.build:gradle至v3.2.1或更高版本
  • 将CompileSDK版本升级到28或更高版本
  • 更新应用程序以使用Jetpack(AndroidX);按照中的说明操作

  • 您的问题出现在您的AndroidManifest.xml中,错误提示在您的清单的应用程序标记中添加
    tools:replace=“android:appComponentFactory”
    ,这是由于重复性,请尝试添加您的清单,以便有人可以帮助您更好地检查此问题您的AndroidManifest.xml中,错误提示在清单的应用程序标记中添加
    tools:replace=“android:appComponentFactory”
    ,这是由于重复性造成的。请尝试添加清单,以便有人能够帮助更好地检查此清单
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            google()
            jcenter()
    
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.3.1'
            classpath 'com.google.gms:google-services:4.3.3'
    
    
            // 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
    }