在 gradle 中插入 AdMob 或 Firebase 代码时出错
Error occured during insertion of AdMob or Firebase Codes in gradle
我有 android studio 项目,当我在 gradle 中插入 AdMob 或 Firebase 代码时,看到这个错误
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:8:1-25:15 to override.
这是我的清单
manifest
这是gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
将此代码添加到 <application>
后即可正常工作
tools:replace="android:appComponentFactory"
android:appComponentFactory="androidx"
新的Firebase libraries and the new Google Play Libraries需要androidx。
由于您正在使用这些库,因此您同时使用了支持库和 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
或更高版本。
- 将
compileSdkVersion
升级到 28
或更高版本。
- 更新您的应用以使用 Jetpack (AndroidX);按照 Migrating to AndroidX.
中的说明进行操作
我有 android studio 项目,当我在 gradle 中插入 AdMob 或 Firebase 代码时,看到这个错误
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:8:1-25:15 to override.
这是我的清单 manifest
这是gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
将此代码添加到 <application>
tools:replace="android:appComponentFactory"
android:appComponentFactory="androidx"
新的Firebase libraries and the new Google Play Libraries需要androidx。 由于您正在使用这些库,因此您同时使用了支持库和 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
或更高版本。 - 将
compileSdkVersion
升级到28
或更高版本。 - 更新您的应用以使用 Jetpack (AndroidX);按照 Migrating to AndroidX. 中的说明进行操作