3

When I updated my Android Studio 3.0, I get an error

unable to merge with dex.

Then I added mutiDexEnabled true and also added com.android.support:multidex:1.0.1 in build.gradle.

Then I'm getting the error below:

Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. java.io.IOException: Can't write [C:\Users\user\AndroidStudioProjects\KnightFox-IN BUDGET\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't read [C:\Users\user.gradle\caches\transforms-1\files-1.1\play-services-ads-lite-11.4.2.aar\9a54afd7907fee993ecc421b66ed4228\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:com/google/ads/mediation/MediationServerParameters$Parameter.class]))

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.copperseeds.android.kunjachamman.applicationin.budget"
        minSdkVersion 14
        targetSdkVersion 26
        multiDexEnabled true
    }


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

}



dependencies {
    implementation files('libs/ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation 'com.android.support:appcompat-v7:26.0.0'
    implementation 'com.android.support:support-annotations:26.0.0'
    implementation 'com.android.support:support-v4:26.0.0'
    implementation 'com.github.navasmdc:MaterialDesign:1.5@aar'
    testImplementation 'junit:junit:4.12'
    implementation project(':ORMDroid')
    implementation project(':FacebookSDK')
    implementation project(':standOut')
    implementation files('libs/gcm.jar')
    implementation files('libs/google-play-services.jar')
    implementation 'com.google.android.gms:play-services:+'
    compile 'com.android.support:multidex:1.0.1'    
}
clemens
  • 16,716
  • 11
  • 50
  • 65
jasmin
  • 61
  • 6

6 Answers6

1

Try delete build folder of app than Clean-Rebuild-Run your Project. if not work than do Invalidate Caches/Restart.

Happy coding!!

Hemant Parmar
  • 3,924
  • 7
  • 25
  • 49
0

Try buildToolsVersion "26.0.0" and then just restart Android Studio.

0

You don't need to add jar files for Play services when you adding dependencies

remove this from your Build.Gradle

implementation files('libs/google-play-services.jar')

than Clear-Rebuild-Run your Project

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

Once try these steps,

Step 1: Delete all the build and the .gradle folder,

Step 2: Add the below code in your gradle.properties,

 android.enableAapt2=false

Step 3: Then Sync your android project.

Aman Gupta - ΔMΔN
  • 2,971
  • 2
  • 19
  • 39
  • i cant see the gradle.properties – jasmin Nov 02 '17 at 09:23
  • If not there you can create resource bundle by clicking right click on project, **Right click on the Project -> New - >Resource Bundle**. Then create a file named **gradle**. Your **gradle.properties** file will be show just below of **build.gradle** file. Then write this code there. – Aman Gupta - ΔMΔN Nov 02 '17 at 12:02
0

You should not work with librairies that end with + . You should specify a version. implementation 'com.google.android.gms:play-services:+' should be

implementation 'com.google.android.gms:play-services:11.4.2'

then build.gradle will be :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.copperseeds.android.kunjachamman.applicationin.budget"
        minSdkVersion 14
        targetSdkVersion 26
        multiDexEnabled true
    }


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

}



dependencies {
    implementation files('libs/ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    implementation 'com.android.support:appcompat-v7:26.0.0'
    implementation 'com.android.support:support-annotations:26.0.0'
    implementation 'com.android.support:support-v4:26.0.0'
    implementation 'com.github.navasmdc:MaterialDesign:1.5@aar'
    testImplementation 'junit:junit:4.12'
    implementation project(':ORMDroid')
    implementation project(':FacebookSDK')
    implementation project(':standOut')
    implementation files('libs/gcm.jar')
    implementation files('libs/google-play-services.jar')
    implementation 'com.google.android.gms:play-services:11.4.2'
    compile 'com.android.support:multidex:1.0.1'    
}
Nawrez
  • 3,314
  • 8
  • 28
  • 42
0

You need to still add in manifest if you are not extending application class

  <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>

If you are extending application class then follow details in this link:

https://developer.android.com/studio/build/multidex.html

Do not use jars, just use the repos directly

do not use compile use implimentation

Also you need to update to Android Studio version 3.0. Also make sure you added the new repo in root gradle.build:

repositories {
    maven {
        url 'https://maven.google.com'
    }
}

You may also use with newer gradle wrapper

repositories {
        maven {
            google()
        }
    }

If you have used data binding in repo then make sure you have added

android {
    ....
    dataBinding {
        enabled = true
    }
}

This is the best way to do it.

In your root level gradle.build use below

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

and in your gradle-wrapper.properties file change the wrapper version as below

distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip

Also in your app level build.gradle make sure you are using 26 version as below

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.xxxx"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Niraj Sanghani
  • 1,493
  • 15
  • 23