0

I am looking for the answer that can help me to solve this problem. I am trying to solve this problem for last 2 days.But still, I didn't get the answer that can solve my problem. I have tried so many solutions which are given here.But no solution worked for me. Please help me to solve this problem.Any help will be appreciated.

The actual problem is:

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

this is occurring every time when I run my existing project on android studio 3.0

I have tried so many solutions for this like:

1- To add mutidexenabled true in gradle

2- To change the version of dependencies

3- To change the compile keyword with the implementation

4- To clean and rebuild the project

5- Delete the Gradle file(this was so difficult because when you again restarted the project no Gradle file will be auto-regenerated) etc.

I am looking for the solutions which are other than those which are mentioned above. Please help me out. Please...

code of gradle file is given below:

apply plugin: 'com.android.application'
buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'io.fabric'

repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }

    flatDir {
        dirs 'libs'
    }
}
repositories {
    maven { url 'http://clojars.org/repo' }
}

android {
    signingConfigs {
        config {
            keyAlias 'example'
            keyPassword 'example'
            storeFile file('/Users/standarduser/Documents/Android_Projects/example.jks')
            storePassword '@@@@@@@@'
        }
    }
    compileSdkVersion 25
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId 'com.example.example'
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 9  // both Latest
        versionName "2.0.7"
        multiDexEnabled true
        useLibrary 'org.apache.http.legacy'
        vectorDrawables.useSupportLibrary = true
        signingConfig signingConfigs.config
    }
    dexOptions {
        incremental = true
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
    android {
        packagingOptions
                {
                    exclude 'META-INF/DEPENDENCIES.txt'
                    exclude 'META-INF/LICENSE.txt'
                    exclude 'META-INF/NOTICE.txt'
                    exclude 'META-INF/NOTICE'
                    exclude 'META-INF/LICENSE'
                    exclude 'META-INF/DEPENDENCIES'
                    exclude 'META-INF/notice.txt'
                    exclude 'META-INF/license.txt'
                    exclude 'META-INF/dependencies.txt'
                    exclude 'META-INF/LGPL2.1'
                }
    }

    lintOptions{
        abortOnError false
    }
}

dependencies {
    compile files('libs/httpcore-4.4.1.jar')
    compile('com.twitter.sdk.android:twitter:2.1.1@aar') { //1.6.1@aar
        transitive = true;
    }
    compile('com.github.afollestad.material-dialogs:core:0.8.5.2@aar') {
        transitive = true
    }
    compile('io.socket:socket.io-client:0.8.2') { // 0.6.3
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }
    testCompile 'junit:junit:4.12'
    compile 'com.writingminds:FFmpegAndroid:0.3.2'
    compile 'com.mcxiaoke.volley:library:1.0.19'
    compile 'io.nlopez.smartlocation:library:3.2.9'
    //   compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.android.gms:play-services-appinvite:9.8.0'
    //9.0.1
    compile 'com.google.android.gms:play-services-gcm:9.8.0'
    compile 'com.google.android.gms:play-services-location:9.8.0'
    compile 'com.google.android.gms:play-services-places:9.8.0'
    compile 'com.google.android.gms:play-services-maps:9.8.0'
    compile 'com.google.android.gms:play-services-ads:9.8.0'
    compile 'com.google.android.gms:play-services-auth:9.8.0'
    compile 'com.google.android.gms:play-services-plus:9.8.0'
    //noinspection GradleCompatible
    compile 'com.android.support:appcompat-v7:25.3.0'
    compile 'com.android.support:design:25.0.1'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'org.apache.httpcomponents:httpmime:4.3.5'
//    implementation 'org.apache.httpcomponents:httpmime:4.3.6'
//    implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.facebook.android:facebook-android-sdk:4.23.0'
    compile 'com.pusher:pusher-java-client:1.1.2'
    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    compile 'com.daimajia.swipelayout:library:1.2.0@aar'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.6'
    compile 'com.amazonaws:aws-android-sdk-mobileanalytics:2.2.9'
    compile 'com.commit451:PhotoView:1.2.4'
    compile 'commons-lang:commons-lang:2.3'
    compile 'com.karumi:dexter:2.3.1'
    compile 'com.jakewharton:butterknife:8.5.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
    implementation 'com.android.support:multidex:1.0.2'
    compile 'org.ocpsoft.prettytime:prettytime:3.2.7.Final'
    compile 'com.koushikdutta.async:androidasync:2.+'
    compile 'com.soundcloud.android:android-crop:1.0.1@aar'
    compile 'net.danlew:android.joda:2.9.4.1'
    compile 'com.albinmathew:photo-crop-library:1.0.3'
    compile 'com.amazonaws:aws-android-sdk-core:2.2.+'
    compile 'com.amazonaws:aws-android-sdk-s3:2.2.+'
    compile 'com.wang.avi:library:2.1.3'
    compile 'com.wowza.gocoder.sdk.android:com.wowza.gocoder.sdk:1.0b7@aar'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.4@aar') {
        transitive = true;
    }
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    //    compile 'com.cocosw:bottomsheet:1.+@aar'
    compile project(':libbambuser7')
    compile 'com.squareup.okhttp:okhttp:2.0.0'
}

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

2 Answers2

0

Add this in your build.gradle

android {
    defaultConfig {
       multiDexEnabled true
    }
}
  • First sync gradle then
  • From the Build menu -> press the Clean Project button.
  • When task completed, press the Rebuild Project button from the Build menu.
  • compile is now deprecated so it's better to use implementation or api

hope this helps you.

InsaneCat
  • 2,115
  • 5
  • 21
  • 40
0

Try this

Use this

com.google.android.gms:play-services:11.6.0

com.google.android.gms:play-services-location:11.6.0 

Instead of this

com.google.android.gms:play-services:9.8.0

after Sync -> clean -> rebuild

Ratilal Chopda
  • 4,162
  • 4
  • 18
  • 31