如何修复“清单合并错误"由于 Firebase 数据库实施 [英] How to fix "manifest merger error" due to the Firebase Database implementation
问题描述
我正在编写一个 23 API 应用程序,我需要添加 Firebase 数据库服务.当我添加行
I'm coding an 23 API app, and i need to add Firebase Database services. When i add the line
实现'com.google.firebase:firebase-database:18.0.0
在 gradle 应用程序中,我尝试同步,但显示失败:
in the gradle app and i try to sync, it failes showing this:
ERROR: 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:15:5-48:19 to override.
有人可以帮我吗?
这是我的应用程序 gradle 文件
This is my app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.QUeM.TreGStore"
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'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
// Glide image library
implementation 'com.github.bumptech.glide:glide:4.3.1'
//dipendenza per firebase
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-database:18.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
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.android.gms:play-services-vision:11.8.0'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
//plugin per l'utilizzo di firebase
apply plugin: 'com.google.gms.google-services'
推荐答案
如果你想使用 implementation 'com.google.firebase:firebase-database:18.0.0
那么你必须这样做以下:
If you want to use implementation 'com.google.firebase:firebase-database:18.0.0
then you have to do the following:
来自文档:
此版本是主要版本更新,包括重大更改.在此版本中,库从 Android 支持库迁移到 Jetpack (AndroidX) 库.除非您在应用中进行以下更改,否则更新后的库将无法使用:
This release is a MAJOR version update and includes breaking changes. With this release, libraries are migrated from the Android Support Libraries to the Jetpack (AndroidX) Libraries. The updated libraries will not work unless you make the following changes in your app:
将
com.android.tools.build:gradle
升级到 v3.2.1 或更高版本.
Upgrade
com.android.tools.build:gradle
to v3.2.1 or later.
将 compileSdkVersion
升级到 28 或更高版本.
Upgrade compileSdkVersion
to 28 or later.
要将其他依赖项迁移到 androidx
包,您可以执行以下操作:
To migrate the other dependencies to androidx
package, you can do the following:
使用 Android Studio 3.2 及更高版本,您可以通过从菜单栏中选择重构 > 迁移到 AndroidX 来快速迁移现有项目以使用 AndroidX.
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.
查看更多信息:
https://developer.android.com/jetpack/androidx/migrate#migrate
这篇关于如何修复“清单合并错误"由于 Firebase 数据库实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!