将 WorkManager 添加为依赖项时清单合并失败

Manifest merger failed while adding WorkManager as dependency

提问人:Piyush Mishra 提问时间:5/2/2019 更新时间:5/2/2019 访问量:423

问:

我正在将 WorkManager 添加为依赖项,但陷入了错误。我收到错误 请解释问题是什么以及如何解决它。Manifest merger failed

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:10:5-24:19 to override.

我在主要方向上的build.gradle是这个

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我在应用程序目录中的build.gradle是这个

应用

 plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "sng.urrsm.calllog"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation "androidx.work:work-runtime:2.0.1"
    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'
}

我添加了 build.gradle,它存在于 app 目录中。implementation "androidx.work:work-runtime:2.0.1"

java android 智能 gradle-plugin

评论

0赞 CommonsWare 5/2/2019
将所有内容移至 AndroidX。因此,您的工件将成为 AndroidX 的等价物,您需要更改这些类的用途以匹配。com.android.support
0赞 Piyush Mishra 5/2/2019
请解释一下我是怎么做到的?
0赞 CommonsWare 5/2/2019
developer.android.com/jetpack/androidx/migrate
0赞 Amin 5/19/2021
我有同样的问题。我不能轻易迁移到AndroidX,这是一个非常大的项目,修复迁移到AndroidX后会发生的一些错误需要太多时间。

答: 暂无答案