Gradle 生成 APK -- 条目名称 'META-INF/androidx.hilt_hilt-common.version' 发生冲突

Gradle generating APK -- Entry name 'META-INF/androidx.hilt_hilt-common.version' collided

我在生成 APK 时突然遇到这个构建问题。我不知道这意味着什么或如何解决它。我对上次构建所做的更改很小,我什至没有运气就恢复到以前的版本。请协助:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageStaging'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Entry name 'META-INF/androidx.hilt_hilt-common.version' collided

更新:运行 app:dependencies

+--- androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02
|    +--- androidx.annotation:annotation:1.1.0
|    +--- androidx.hilt:hilt-common:1.0.0-alpha02
|    +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.2.0 (*)
|    \--- com.google.dagger:hilt-android:2.28-alpha (*)


+--- com.google.dagger:hilt-android:{strictly 2.28-alpha} -> 2.28-alpha (c)

+--- androidx.hilt:hilt-common:{strictly 1.0.0-alpha02} -> 1.0.0-alpha02 (c)

+--- com.google.dagger:hilt-android:2.28-alpha
|    +--- com.google.dagger:dagger:2.28
|    |    \--- javax.inject:javax.inject:1
|    +--- com.google.dagger:dagger-lint-aar:2.28
|    +--- com.google.code.findbugs:jsr305:3.0.1
|    +--- androidx.activity:activity:1.1.0
|    |    +--- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.core:core:1.1.0 -> 1.3.0 (*)
|    |    +--- androidx.lifecycle:lifecycle-runtime:2.2.0 (*)
|    |    +--- androidx.lifecycle:lifecycle-viewmodel:2.2.0
|    |    |    \--- androidx.annotation:annotation:1.1.0
|    |    +--- androidx.savedstate:savedstate:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.1.0
|    |    |    +--- androidx.arch.core:core-common:2.0.1 -> 2.1.0 (*)
|    |    |    \--- androidx.lifecycle:lifecycle-common:2.0.0 -> 2.2.0 (*)
|    |    \--- androidx.lifecycle:lifecycle-viewmodel-savedstate:1.0.0 -> 2.2.0
|    |         +--- androidx.annotation:annotation:1.0.0 -> 1.1.0
|    |         +--- androidx.savedstate:savedstate:1.0.0 (*)
|    |         +--- androidx.lifecycle:lifecycle-livedata-core:2.2.0
|    |         |    +--- androidx.lifecycle:lifecycle-common:2.2.0 (*)
|    |         |    +--- androidx.arch.core:core-common:2.1.0 (*)
|    |         |    \--- androidx.arch.core:core-runtime:2.1.0
|    |         |         +--- androidx.annotation:annotation:1.1.0
|    |         |         \--- androidx.arch.core:core-common:[2.1.0] -> 2.1.0 (*)
|    |         \--- androidx.lifecycle:lifecycle-viewmodel:2.2.0 (*)





乍一看,您的依赖项似乎存在冲突 - 我怀疑您的项目中包含 2 个不同版本的 Hilt。

请 运行 Gradle :app:dependencies 任务(或与您的项目结构相对应的任务)并检查输出以验证可能导致冲突的原因(搜索 Hilt 条目).

原来我的情况是 Android 工作室的一个错误。我复制了“staging”并将其命名为“staging2”,它运行良好。