清单合并因多个错误而失败,android

Manifest merger failed with multiple errors , android

我在我的应用程序中使用工作管理器

工作管理器版本implementation 'androidx.work:work-runtime:2.7.1'

我在清单中添加了

<provider
        android:name="androidx.startup.InitializationProvider"
        android:authorities="${applicationId}.workmanager-init"
        tools:node="remove" />

并将其添加到清单中的应用程序标签中 tools:replace="android:authorities"

当我构建应用程序时出现错误

Caused by: java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
at com.android.build.gradle.internal.tasks.manifest.ManifestHelperKt.mergeManifests(ManifestHelper.kt:87)
at com.android.build.gradle.tasks.ProcessApplicationManifest.doFullTaskAction(ProcessApplicationManifest.kt:144)
at com.android.build.gradle.internal.tasks.IncrementalTask.handleIncrementalInputs(IncrementalTask.kt:112)
at com.android.build.gradle.internal.tasks.IncrementalTask.access$handleIncrementalInputs(IncrementalTask.kt:65)
at com.android.build.gradle.internal.tasks.IncrementalTask$taskAction$$inlined$recordTaskAction.invoke(BaseTask.kt:65)
at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)

在清单合并中我看到这个错误

Merging Errors: Error: tools:replace specified at line:6 for attribute android:authorities, but no new value specified My_Application.app main manifest (this file), line 5 Error: Validation failed, exiting My_Application.app main manifest (this file) 

这是我的申请class

class App : Application(), Configuration.Provider {
override fun onCreate() {
    super.onCreate()

}

override fun getWorkManagerConfiguration(): Configuration =
    Configuration.Builder()
        .setMinimumLoggingLevel(android.util.Log.DEBUG)
        .build()

}

您似乎使用了错误的配置:

自 WorkManager 2.6 起,App Startup 在 WorkManager 内部使用。要提供自定义初始化程序,您需要删除 androidx.startup 节点。

<!-- If you want to disable android.startup completely. -->
 <provider
    android:name="androidx.startup.InitializationProvider"
    android:authorities="${applicationId}.androidx-startup"
    tools:node="remove">
 </provider>

https://developer.android.com/topic/libraries/architecture/workmanager/advanced/custom-configuration#remove-default