Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dex error On Android Studio 3.0 Beta4

Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Error:com.android.dex.DexException: Multiple dex files define Lcom/google/zxing/integration/android/IntentResult;
like image 764
Ankita-user3449434 Avatar asked Sep 05 '17 11:09

Ankita-user3449434


3 Answers

I have same problem with Android Studio 3.0 beta 4. I found a solution.

1. From the Build menu, press the Clean Project button.

Clean Project

2. After task completed, press the Rebuild Project button from the Build menu.

enter image description here

like image 130
Y.E.S. Avatar answered Nov 14 '22 08:11

Y.E.S.


For Android Studio 3.0 what I did was to add this to my gradle:

multiDexEnabled true

And it worked!

Example

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.xx.xxx"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 9
        versionName "1.0"
        multiDexEnabled true //Add this
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
like image 28
Prodigy Avatar answered Nov 14 '22 08:11

Prodigy


So I solved this issue by doing the following:

  • Delete the ./gradle folder inside your project
  • Delete all the build folders and the gradle cache. I ran the following command:

How ?

 cd ~/[your project root folder] && find . -name build -exec rm -rf {} \; && rm -rf $HOME/.gradle/caches/

Assuming your gradle config files are in the $HOME/.gradle folder.

  • Inside Android Studio, went to File > Invalidate caches / Restart... and invalidated the caches and restarted it.
like image 19
ADev Avatar answered Nov 14 '22 09:11

ADev