【问题标题】:merge manifest error when add material dependency添加材质依赖时合并清单错误
【发布时间】:2020-01-17 03:38:57
【问题描述】:

添加时

implementation 'com.google.android.material:material:1.1.0-alpha10'

在 gradle 文件中构建错误是:

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.1.0-rc03] AndroidManifest.xml:24:18-86 value=(androidx.core.app.CoreComponentFactory).
    Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:10:5-36:19 to override.

当在清单文件中添加tools:replace="android:appComponentFactory" 时,我遇到了另一个错误 新的错误信息是:Manifest merge failed with multiple errors,查看日志

我的 geadle 文件:

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
    applicationId "com.saat.ali.hozorghiab"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 6
    versionName '1.6'
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v4:28.0.0'
implementation 'android.arch.lifecycle:extensions:1.1.1'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
//implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.android.support:design:28.0.0'
androidTestImplementation 'junit:junit:4.12'
implementation 'com.github.florent37:materialtextfield:1.0.7'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'

implementation 'com.google.android.material:material:1.1.0-alpha10'

implementation 'com.github.ittianyu:BottomNavigationViewEx:2.0.4'
//testImplementation 'org.testng:testng:6.9.6'

}

【问题讨论】:

标签: android material-design androidx android-design-library material-components-android


【解决方案1】:

查看材料组件库的official doc

如果您的应用当前依赖于原始设计支持库,您可以使用 Android Studio 提供的 Refactor to AndroidX... 选项。这样做会更新您应用的依赖项和代码,以使用新打包的 androidxcom.google.android.material 库。

如果您还不想切换到新的 androidxcom.google.android.material 包,可以通过 com.android.support:design:28.0.0 依赖项使用 Material Components。

注意:您不应在您的应用中同时使用com.android.supportcom.google.android.material 依赖项。

您必须使用 AndroidX 库。

【讨论】:

    【解决方案2】:

    尝试迁移到 AndroidX,要做到这一点,请转到 Refactor -> Migrate to AndroidX,大多数关于清单合并的问题都可以通过 AndroidX 解决。 最酷的部分是迁移非常安全,迁移我的项目从来没有任何问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-17
      • 1970-01-01
      • 2017-09-17
      • 2018-12-12
      • 2020-05-29
      • 2016-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多