0

I have an android project created with android studio 2.3. Now I have upgraded to android studio 3 and I have the following error.

When I ran my app it compiles normally and is installed in my device. It works fine. Any changes I make to the code are visible in the device.

But when I try to rebuild i get the following error:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

this happens only on rebuild. I have tried to clean and rebuild and also i have done invalidate cache/Restart.

What is the problem?

EDIT: My app gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "gr.myapp1"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "2.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile project(':CoreServices-3.14.5')
    compile project(':maflogoncore-1.214.5')
    //compile project(':maflogonui-1.214.5')
    compile project(':mafsettingscreen-1.214.5')
    compile project(':mafuicomponents-1.214.5')
    compile project(':MobilePlace-3.14.5')
    compile project(':ODataOnline-3.14.5')
    compile project(':Request-3.14.5')
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.android.support:support-vector-drawable:25.3.1'
    compile 'com.google.android.gms:play-services:11.0.2'
    compile 'com.google.maps.android:android-maps-utils:0.4'
    compile 'com.android.support:cardview-v7:25.3.1'
    testCompile 'junit:junit:4.12'
}

//firebase
apply plugin: 'com.google.gms.google-services'

my project gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'

        //firebase
        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()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
mike_x_
  • 1,900
  • 3
  • 35
  • 69

1 Answers1

0

Eventually i had to enable multidex although i had minimumVersion: 21

Maybe because when i created the project i had it set to 19 and i changed it to 21.

I haven't found why it worked all this time without multidex and now that i upgraded to Android studio 3 it requires it.

mike_x_
  • 1,900
  • 3
  • 35
  • 69