Android Material 和 appcompat Manifest 合并失败

标签 android android-gradle-plugin build.gradle gradle-plugin

我有下一个年级

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    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.material:material:1.0.0-rc01'
}

但是当我想构建应用程序时,我会得到下一个日志:

Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0-alpha3] AndroidManifest.xml:22:18-91
    is also present at [androidx.core:core:1.0.0-alpha3] 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.

好吧!去 manifest 做吧:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="ru.chopcode.myapplication">

    <application
        tools:replace="android:appComponentFactory"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
    </application>

</manifest>

然后我的 Logcat 中出现此错误:

Manifest merger failed with multiple errors, see logs that I have Linked with it

最佳答案

我有类似的问题。在 gradle.properties 文件中添加了两行:

android.useAndroidX=true
android.enableJetifier=true

这两行自动解决了我在 google 文件和第三方依赖项之间的依赖项冲突。以下是链接:https://developer.android.com/topic/libraries/support-library/androidx-overview#new-project

关于Android Material 和 appcompat Manifest 合并失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51793345/

相关文章:

android - 表格行内的 TextView 内容被截断

java - 添加库后不断收到错误 Gradle Build 失败,出现异常 : java. exe' 以非零退出值 2 完成

android - 错误 :(6, 0) 未找到 Gradle DSL 方法: 'google()'

java - BuildConfig 多个 dex 文件错误 (Gradle 3.0.1)

android - 我如何在 "build.gradle"应用程序中分离库版本

java - 如何通过fragment中的地址位置实现Google map 搜索

android - 如何从Jenkins访问 'versionName'属性(在我的Android gradle文件中)?

android - 程序类型已经存在:com.squareup.picasso.Action $ RequestWeakReference

android - androidTestImplementation Google Truth 1.0 和实现 Google Guava 27.0.1 无法满足的版本约束

java - 如何更新 Room 数据库中的现有行?