尝试连接到 Firebase 时清单合并失败
Manifest merger failed when try to connect to firebase
我正在尝试将我的应用与 firebase 连接,所以我添加了
我的 graddle 文件的类路径、实现和 "apply plugin"
但是当我尝试 运行 一个应用程序时,出现了这个错误:
清单合并失败:属性 application@appComponentFactory value=(android.sustrong textpport.v4.app.CoreComponentFactory) 来自 [com.android.su pport:support-compat:28.0.0] 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)。
您可以查看以下说明link:
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.
尝试将您的项目迁移到 AndroidX 我遇到了同样的问题并已解决
我正在尝试将我的应用与 firebase 连接,所以我添加了
我的 graddle 文件的类路径、实现和 "apply plugin"
但是当我尝试 运行 一个应用程序时,出现了这个错误:
清单合并失败:属性 application@appComponentFactory value=(android.sustrong textpport.v4.app.CoreComponentFactory) 来自 [com.android.su pport:support-compat:28.0.0] 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)。
您可以查看以下说明link:
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.
尝试将您的项目迁移到 AndroidX 我遇到了同样的问题并已解决