Gradle 构建错误将字节码转换为 dex 时出错:原因:com.android.dex.DexException:多个 dex 文件定义了 Landroid/arch/lifecycle/liveData$1

Gradle 构建错误将字节码转换为 dex 时出错:原因:com.android.dex.DexException:多个 dex 文件定义了 Landroid/arch/lifecycle/liveData$1

问题描述:

从过去 3 天开始,我收到此错误并已尽我所能.谁能帮我纠正一下.我正在使用 Android 3.0 并且我的 sdk 和 Google Play 服务已更新,并且我已将 multiDexEnabled true 添加到我的代码中...并且还尝试删除 .gradle 和 .idea 文件夹并再次重建....但错误仍然存​​在任何帮助将不胜感激

From last 3 days I'm getting this error and have tried all i could. Can anyone help me correct it. I'm using Android 3.0 and my sdk and Google play services are updated as well as i have addedmultiDexEnabled true to my code...and also tried deleting the .gradle and .idea folders and again rebuilding the....but the error is still there any help would be appreciated

将字节码转换为 dex 时出错:原因:com.android.dex.DexException: 多个 dex 文件定义landroid/arch/lifecycle/liveData$1;

Error converting bytecode to dex: Cause: com.android.dex.DexException:Multiple dex files define Landroid/arch/lifecycle/liveData$1;

我刚刚遇到了同样的问题,并通过更新生命周期库的版本来修复它:

I've just met the same issue and fixed it by updating the version of lifecycle library:

implementation 'android.arch.lifecycle:runtime:1.1.0'
implementation 'android.arch.lifecycle:extensions:1.1.0'
implementation 'android.arch.lifecycle:compiler:1.1.0'

似乎在我的项目中使用的另一个库声明了 1.1.0 版本,但我使用的是 1.0.0.

It seems that another library using in my project declare the version 1.1.0, but i was using 1.0.0.