清单合并失败:属性 application@appComponentFactory 正在更新 Firebase 库
Manifest merger failed : Attribute application@appComponentFactory updating Firebase libraries
我正在尝试在我的项目中添加 firebase 但是当我实施 'com.google.firebase:firebase-messaging:19.0.0'
和 'com.google.firebase:firebase-core:17.0.0'
.
build.gradle
(这里是错误)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.user.mikripoli"
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "2g"
}
}
dependencies {
implementation 'com.roughike:bottom-bar:2.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.flaviofaria:kenburnsview:1.0.7'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.4'
implementation 'com.google.firebase:firebase-messaging:19.0.0'
implementation 'com.google.firebase:firebase-core:17.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 "com.google.android.gms:play-services-location:17.0.0"
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-base:17.0.0'
implementation 'com.github.ahmedshaban1:EasySlider:1.0.0'
implementation 'com.liangfeizc:SlidePageIndicator:1.1.0@aar'
implementation 'me.relex:circleindicator:1.2.2@aar'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
另一个gradle文件:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
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()
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
关于com.android.support:support-v4:28.0.0
显示的错误:
Dependencies using groupId com.android.support and androidx.* can not
be combined but found
IdeMavenCoordinates{myGroupId='com.android.support',
myArtifactId='cardview-v7', myVersion='28.0.0', myPacking='aar',
myClassifier='null'} and
IdeMavenCoordinates{myGroupId='androidx.coordinatorlayout',
myArtifactId='coordinatorlayout', myVersion='1.0.0', myPacking='aar',
myClassifier='null'} incompatible dependencies
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).
另外 当我构建 apk 时它显示此错误:
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 element
at AndroidManifest.xml:13:5-354:19 to override.
adding tools:replace="android:appComponentFactory" doesn't work though
试试这个并同步你的项目,如果这对你有帮助的话
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
在新版本中,库从 Android 支持库迁移到 Jetpack (AndroidX) 库。
除非您在应用中进行以下更改,否则更新后的库将无法使用:
升级 com.android.tools.build:gradle 到 v3.2.1 或更高版本。
将compileSdkVersion升级到28以上
更新您的应用以使用 Jetpack (AndroidX);按照 Migrating to AndroidX.
中的说明进行操作
方法一:
将这两个添加到您的 gradle.properties 文件中,不更新任何内容
android.useAndroidX=true
android.enableJetifier=true
方法二
如果方法一不能解决你的问题
做一件事
如果您使用的是 android Studio 3.2 或更高版本
转到 重构 > 迁移到 AndroidX...
要么将这些 Firebase
依赖项降级 - 要么将 migrate 降级为 androidx
。
Jetifier 相当无用,因为它控制了 自己的 依赖项。
您同时使用了支持库和 androidx 库,但您做不到。
Cloud Messaging 版本 19.0.0 在 6 月发布。检查 Firebase 库的 official release notes:
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
或更高版本。
- 将
compileSdkVersion
升级到 28
或更高版本。
- 更新您的应用以使用 Jetpack (AndroidX);按照 Migrating to AndroidX.
中的说明进行操作
根据firebase site解决这个问题:
- 更新您的应用程序以使用 Jetpack (AndroidX),您可以通过将以下两行:
android.useAndroidX=true
和 android.enableJetifier=true
添加到项目根目录中的文件 gradle.properties
中来完成此操作。或者你可以做 another method
- 将
com.android.tools.build:gradle
升级到 v3.2.1 或更高版本(在项目 build.gradle
文件中)
- 将
compileSdkVersion
升级到 28 或更高版本(在项目 build.gradle
文件中)
28.0.0 是原始支持库的最后一个版本,不再维护。支持库中存在的所有功能现在都是 AndroidX 命名空间的一部分,Google 建议您移至 AndroidX。
在 Android Studio 3.2 及更高版本中,您可以通过 Refactor->Migrate to AndroidX
进行迁移
但是请注意,如果您对配置进行了专门化处理,则可能需要手动进行一些更改。
这是一个video on the topic and the official documentation
我正在尝试在我的项目中添加 firebase 但是当我实施 'com.google.firebase:firebase-messaging:19.0.0'
和 'com.google.firebase:firebase-core:17.0.0'
.
build.gradle
(这里是错误)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.user.mikripoli"
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "2g"
}
}
dependencies {
implementation 'com.roughike:bottom-bar:2.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.flaviofaria:kenburnsview:1.0.7'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.4'
implementation 'com.google.firebase:firebase-messaging:19.0.0'
implementation 'com.google.firebase:firebase-core:17.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 "com.google.android.gms:play-services-location:17.0.0"
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-base:17.0.0'
implementation 'com.github.ahmedshaban1:EasySlider:1.0.0'
implementation 'com.liangfeizc:SlidePageIndicator:1.1.0@aar'
implementation 'me.relex:circleindicator:1.2.2@aar'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}
另一个gradle文件:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
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()
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
关于com.android.support:support-v4:28.0.0
显示的错误:
Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='cardview-v7', myVersion='28.0.0', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.coordinatorlayout', myArtifactId='coordinatorlayout', myVersion='1.0.0', myPacking='aar', myClassifier='null'} incompatible dependencies
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).
另外 当我构建 apk 时它显示此错误:
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 element at AndroidManifest.xml:13:5-354:19 to override.
adding tools:replace="android:appComponentFactory" doesn't work though
试试这个并同步你的项目,如果这对你有帮助的话
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
在新版本中,库从 Android 支持库迁移到 Jetpack (AndroidX) 库。
除非您在应用中进行以下更改,否则更新后的库将无法使用:
升级 com.android.tools.build:gradle 到 v3.2.1 或更高版本。
将compileSdkVersion升级到28以上
更新您的应用以使用 Jetpack (AndroidX);按照 Migrating to AndroidX.
中的说明进行操作
方法一:
将这两个添加到您的 gradle.properties 文件中,不更新任何内容
android.useAndroidX=true
android.enableJetifier=true
方法二
如果方法一不能解决你的问题 做一件事 如果您使用的是 android Studio 3.2 或更高版本 转到 重构 > 迁移到 AndroidX...
要么将这些 Firebase
依赖项降级 - 要么将 migrate 降级为 androidx
。
Jetifier 相当无用,因为它控制了 自己的 依赖项。
您同时使用了支持库和 androidx 库,但您做不到。
Cloud Messaging 版本 19.0.0 在 6 月发布。检查 Firebase 库的 official release notes:
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
或更高版本。 - 将
compileSdkVersion
升级到28
或更高版本。 - 更新您的应用以使用 Jetpack (AndroidX);按照 Migrating to AndroidX. 中的说明进行操作
根据firebase site解决这个问题:
- 更新您的应用程序以使用 Jetpack (AndroidX),您可以通过将以下两行:
android.useAndroidX=true
和android.enableJetifier=true
添加到项目根目录中的文件gradle.properties
中来完成此操作。或者你可以做 another method - 将
com.android.tools.build:gradle
升级到 v3.2.1 或更高版本(在项目build.gradle
文件中) - 将
compileSdkVersion
升级到 28 或更高版本(在项目build.gradle
文件中)
28.0.0 是原始支持库的最后一个版本,不再维护。支持库中存在的所有功能现在都是 AndroidX 命名空间的一部分,Google 建议您移至 AndroidX。
在 Android Studio 3.2 及更高版本中,您可以通过 Refactor->Migrate to AndroidX
但是请注意,如果您对配置进行了专门化处理,则可能需要手动进行一些更改。
这是一个video on the topic and the official documentation