1

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;

Abhishek kumar
  • 4,347
  • 8
  • 29
  • 44
jp singh
  • 324
  • 2
  • 13
  • refer this link : https://stackoverflow.com/questions/34352591/android-error-converting-byte-to-dex/34353086 – Ali Mar 05 '18 at 10:45
  • also refer this : https://stackoverflow.com/questions/49103576/android-build-gradle-failing-error-apptransformclasseswithmultidexlistfordebug/49103997#49103997 – Ali Mar 05 '18 at 10:46
  • Tried everything in there....still the same – jp singh Mar 05 '18 at 11:10

7 Answers7

6

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.

  • Actually the issue is not of which lifecycle library. Instead when you open packages/libraries/android/arch/lifecycle there will be many files and in my case those files have multiplied themselves. In other words same files with same names in the same place.....and this is casthe issue....i have tried this way as well but no results...thanks for the help...i really appreciate it....but i think i have to know again start from the beginning – jp singh Mar 08 '18 at 12:48
1

Do you have the latest multidex in your gradle dependencies ?

'com.android.support:multidex:1.0.1'

and add this

android {
    dexOptions {
        preDexLibraries = false
    }
}
1

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

Yonas Alemayehu
  • 111
  • 2
  • 8
  • Yes, i have found that in packages under libraries/android/arch/lifecycle there are some files which have been created twice. However I'm not able to delete then...these are read only. Can you please help me with this? – jp singh Mar 06 '18 at 06:41
0

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

goodev
  • 624
  • 1
  • 5
  • 10
0

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

Prodigy
  • 2,094
  • 24
  • 30
0

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"}
Andy
  • 1
  • 1
-1

Did you add the dependence in your build.gradle?

compile 'com.android.support:multidex:1.0.0'
hanli
  • 11
  • 5
  • Yes i have the latest multiDex library `com.android.support:multidex:1.0.0` – jp singh Mar 05 '18 at 10:59
  • I think the package 'android.arch.lifecycle' may be import twice,maybe your library modules import it , and you import it in your main application too. You can try to remove this package's comile in your application level build.gradle. – hanli Mar 05 '18 at 11:14