简体   繁体   English

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

[英]Gradle build error Error converting bytecode to dex:Cause: com.android.dex.DexException:Multiple dex files define Landroid/arch/lifecycle/liveData$1

From last 3 days I'm getting this error and have tried all i could.从过去 3 天开始,我收到此错误并已尽我所能。 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 added multiDexEnabled 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我正在使用 Android 3.0 并且我的 sdk 和 Google Play 服务已更新,并且我已将multiDexEnabled true添加到我的代码中......并且还尝试删除 .gradle 和 .idea 文件夹并再次重建......但是错误仍然存​​在任何帮助将不胜感激

Error converting bytecode to dex: Cause: com.android.dex.DexException:Multiple dex files define Landroid/arch/lifecycle/liveData$1;将字节码转换为 dex 时出错:原因:com.android.dex.DexException:多个 dex 文件定义了 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'

It seems that another library using in my project declare the version 1.1.0, but i was using 1.0.0.似乎在我的项目中使用的另一个库声明了 1.1.0 版本,但我使用的是 1.0.0。

Do you have the latest multidex in your gradle dependencies ?您的 gradle 依赖项中有最新的 multidex 吗?

'com.android.support:multidex:1.0.1'

and add this并添加这个

android {
    dexOptions {
        preDexLibraries = false
    }
}

This should be related to incompatible versions in your gradle library.这应该与您的 gradle 库中的不兼容版本有关。 can you past your gradle libraries here你能在这里过去你的gradle库吗

尝试“文件”菜单下的“无效缓存/重新启动...”菜单。

遇到了同样的问题,我所要做的就是将我使用的所有库更新为各自的新更新并同步 gradle重新构建并再次运行这对我有用

I updated libraries with new version.我用新版本更新了库。 Need to declare all the android base libraries in the same version(If you update some libraries with new version and using some in older one will cause this kind of exception).需要在同一个版本中声明所有的android基础库(如果你用新版本更新了一些库,而在旧版本中使用一些会导致这种异常)。

    ext { archLifecycleVersion = '1.1.0'}

dependencies {
implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleVersion"}

您是否在 build.gradle 中添加了依赖项?

compile 'com.android.support:multidex:1.0.0'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / RNFetchBlob / RNFetchBlobConst; - Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst; 将字节码转换为dex:原因:com.android.dex.DexException:定义了多个dex文件 - converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define 错误:将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / common / api / zza; - Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zza; 错误:com.android.dex.DexException:多个dex文件定义了Ledu / umd / cs / findbugs / annotations / NonNull; - Error:com.android.dex.DexException: Multiple dex files define Ledu/umd/cs/findbugs/annotations/NonNull; 多个dex文件定义了Landroid / arch / lifecycle / LiveData $ LifecycleBoundObserver; - Multiple dex files define Landroid/arch/lifecycle/LiveData$LifecycleBoundObserver; com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / location / places / PlaceReport; - com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/location/places/PlaceReport; com.android.dex.DexException:多个dex文件定义了Lcom / facebook / internal / Utility $ GraphMeRequestWithCacheCallback; - com.android.dex.DexException: Multiple dex files define Lcom/facebook/internal/Utility$GraphMeRequestWithCacheCallback; com.android.dex.DexException:多个dex文件定义Lorg / hamcrest / Description; - com.android.dex.DexException: Multiple dex files define Lorg/hamcrest/Description; 意外的顶级异常:com.android.dex.DexException:多个dex文件定义 - UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define 意外的顶级异常:com.android.dex.DexException:多个dex文件定义 - UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM