android - 添加 Material 依赖项时合并 list 错误

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

添加时

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.

当在 list 文件中添加 tools:replace="android:appComponentFactory" 时,我遇到了另一个错误 新的错误消息是: list 合并失败并出现多个错误,请参阅日志

我的gedle文件:

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'

}

最佳答案

检查official doc Material 组件库:

If your app currently depends on the original Design Support Library, you can make use of the Refactor to AndroidX… option provided by Android Studio. Doing so will update your app's dependencies and code to use the newly packaged androidx and com.google.android.material libraries.

If you don't want to switch over to the new androidx and com.google.android.material packages yet, you can use Material Components via the com.android.support:design:28.0.0 dependency.

Note: You should not use the com.android.support and com.google.android.material dependencies in your app at the same time.

您必须使用 AndroidX 库。

关于android - 添加 Material 依赖项时合并 list 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57954496/

相关文章:

android-studio - android.useAndroidX 属性未启用,为什么要启用?

android - Androidx中的Cardview

android -/dev/ttyUSB0 未在 Android 中创建

android - 如何使用 Kotlin 让 Android 设备进入休眠状态或以编程方式按下电源按钮?

android - 在android应用程序中访问手机的内部存储?

java - 询问互联网是否可用时出现 NullPointerException

android - 新的 android 支持设计库,屏幕外滚动 tablayout 不工作

java - 当我的 Activity 处于横向模式时,如何以纵向模式打开 NavigationDrawer?

android - 为 BottomNavigationView 上的选定图标设置动画

android - Material Design NavigationView 还不兼容 AndroidX 吗?