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

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-09 03:46:29

问题


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

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


回答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.




回答2:


This should be related to incompatible versions in your gradle library. can you past your gradle libraries here




回答3:


Do you have the latest multidex in your gradle dependencies ?

'com.android.support:multidex:1.0.1'

and add this

android {
    dexOptions {
        preDexLibraries = false
    }
}



回答4:


Try the menu "Invalidate Caches / Restart...", under the File menu.




回答5:


Had the same issue, all I had to do was to update all the libraries I was using to their respective new updates and sync the gradle and rebuild and run again This worked for me




回答6:


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).

    ext { archLifecycleVersion = '1.1.0'}

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



回答7:


Did you add the dependence in your build.gradle?

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


来源:https://stackoverflow.com/questions/49108526/gradle-build-error-error-converting-bytecode-to-dexcause-com-android-dex-dexex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!