skip to Main Content

I am developing one project. This is working fine with Android studio 2.3.3, but what happen is when i updated my Android Studio 3.0 and open my project then it can’t assembled and it send me below error Log.

Error Log

Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/IOCase;
Error:com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/IOCase;
Error:    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
Error:  at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
Error:  at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
Error:  at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Error:  at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
Error:  at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
Error:  at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
Error:  at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
Error:  at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
Error:  at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
Error:  at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
Error:  at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error:Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/io/IOCase;

Please don’t make it duplicate because i have tried below all the things

  • Clean project
  • Rebuild project
  • Deleted /.gradle folder in project after Reopen project and clean and rebuild
  • Deleted .gradle cash folder after Reopen project and clean and rebuild

Other think is i checked below stack overflow questions and its answer and other also then also i don’t get the solution.

1. Question, 2. Question, 3. Question, 4. Question and 5. Question

Project level build.gradle file

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.google.gms:google-services:3.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app level build.gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.mypackage"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        // for render script to create blur image
        renderscriptTargetApi 18
        renderscriptSupportModeEnabled true

        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:multidex:1.0.0'
    testCompile 'junit:junit:4.12'

    compile 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

    //google API
    compile 'com.google.firebase:firebase-auth:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.android.gms:play-services-auth:10.0.1'
    compile 'com.google.android.gms:play-services-places:10.0.1'
    compile 'com.google.android.gms:play-services-maps:10.0.1'

    //facebook SDK
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'

    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.2'
    compile ('org.apache.commons:commons-lang3:3.4'){
        exclude module: 'commons-io'
    }

    compile('net.yazeed44.imagepicker:imagepicker:1.3.0') {
        exclude module: 'cam2'
    }
}
apply plugin: 'com.google.gms.google-services'

Please do some help that how i can fix this issue. May i know if you need any thing from my side. Help would be very appreciate. Thank in advance.

2

Answers


  1. I agree with @CommonsWare that there is one another lib also contain commons-io in your project.

    There is an option to fix this conflict issue in gradle dependency. Add below code in your app level build.gralde file.

    configurations.all {
        resolutionStrategy.dependencySubstitution {
            substitute module('org.apache.commons:commons-io:1.3.2') with module('commons-io:commons-io:1.3.2')
        }
    }
    

    Reason is that why that 'org.apache.commons:commons-io:1.3.2' is conflict Check this stack overflow
    question’s answer.

    Note:-
    To know more about apache commons collections and its different versions check this answer

    Login or Signup to reply.
  2. If you’re explicitly including this dependency in your build.gradle file:

    org.apache.commons:commons-io:1.3.2
    

    replace it with this one (or a later version):

    commons-io:commons-io:2.4
    

    You may need to do a clean/rebuild to get rid of a cached version.
    The org.apache... named one is both misnamed and now very out-of-date. Weirdly, some other org.apache... named ones are apparently OK.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search