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.