1

I am getting error

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

I added linked in sdk successfully but when I compile project(':linkedin-sdk') then give me error i tried to resolve this error i also try multiDexEnabled true but still get error this is my app.gradle file

   buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

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

    android {
        compileSdkVersion 26
        buildToolsVersion '26.0.2'
        defaultConfig {
            minSdkVersion 21
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
            multiDexEnabled true

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

        }

    }

    repositories {
        maven { url 'http://developers.quikkly.io/nexus/repository/maven-releases/' }
        maven { url 'http://developers.quikkly.io/nexus/repository/maven-snapshots/' }
        maven { url 'https://maven.fabric.io/public' }
        mavenLocal()
    }

    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 'com.android.support.constraint:constraint-layout:1.0.2'
        compile 'com.android.support:design:25.3.1'
        compile 'com.android.volley:volley:1.0.0'
        compile 'com.facebook.android:facebook-android-sdk:4.27.0'
        compile 'com.intuit.sdp:sdp-android:1.0.4'
        compile 'com.squareup.picasso:picasso:2.5.2'
        testCompile 'junit:junit:4.12'
        compile 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
        compile 'com.brucetoo.pickview:library:1.2.3'
        compile 'com.caverock:androidsvg:1.2.1'
        compile 'commons-io:commons-io:2.5'

        // Pretty color picker
        compile('com.thebluealliance:spectrum:0.7.1') {
            // spectrum uses older support libs, override these with latest.
            exclude group: 'com.android.support'
        }
        compile('net.quikkly.android:quikklycore-lib:1.2.0@aar') {
            transitive = true
        }
        compile 'net.quikkly.android:quikkly-lib:1.2.0@aar'
        compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
            transitive = true;
        }
        // Include all the Twitter APIs
        compile 'com.twitter.sdk.android:twitter:3.1.1'
        // (Optional) Monetize using mopub
        compile 'com.twitter.sdk.android:twitter-mopub:3.1.1'
        implementation 'com.android.support:support-v13:26.1.0'
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support:support-v4:26.1.0'
        implementation 'com.android.support:support-vector-drawable:26.1.0'

    }

this is my linkedin gradle file

allprojects {
    repositories {
        mavenCentral()
    }
}

buildscript {
   repositories {
     mavenCentral()
   }

}

apply plugin: 'android-library'

android {
    sourceSets {
        androidTest {
          setRoot('src/test')
        }
    }
    compileSdkVersion 17 
    buildToolsVersion '26.0.2'

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 16 
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
          abortOnError false
    }
}

configurations {
}


dependencies {
    compile 'com.android.support:support-annotations:20.0.0'
    compile 'com.android.support:support-v4:21.0.+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/volley.jar')
    androidTestCompile('junit:junit:4.12')
}

I used android studio 3.0 RC 2 with cannery if any kind of help or suggestion please let me know thank in advances
EDIT:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Abhishek Bhardwaj
  • 1,164
  • 3
  • 14
  • 39
Jatin Devani
  • 41
  • 1
  • 7

3 Answers3

0

Use this in your linkedin gradle file:

allprojects
{
    repositories
    {
        maven
        {
            url "https://maven.google.com"
        }
    }
}
Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
Rakesh Polo
  • 431
  • 1
  • 9
  • 27
0
android {
    defaultConfig {
       multiDexEnabled true
    }
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

public class ApplicationClass extends MultiDexApplication {
 @Override
    public void onCreate() {
        super.onCreate();
    }
}
Amjad Khan
  • 1,309
  • 15
  • 32
0

I am putting up the complete MultidexApplication code

app gradle

android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 26
        multiDexEnabled true
    }
    ...
}

dependencies {
  compile 'com.android.support:multidex:1.0.1'
}

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
</manifest>

If you do override the Application class, change it to extend MultiDexApplication (if possible) as follows:

public class MyApplication extends MultiDexApplication { ... }

Or if you do override the Application class but it's not possible to change the base class, then you can instead override the attachBaseContext() method and call MultiDex.install(this) to enable multidex:

public class MyApplication extends SomeOtherApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

Caution: Do not execute MultiDex.install() or any other code through reflection or JNI before MultiDex.install() is complete. Multidex tracing will not follow those calls, causing ClassNotFoundException or verify errors due to a bad class partition between DEX files.

Amjad Khan
  • 1,309
  • 15
  • 32