I getting this error when i used the Facebook audience network SDK.
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'. java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
My app level gradle
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.xyz.abc"
minSdkVersion 16
targetSdkVersion 27
versionCode 8
versionName "1.1"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g"
jumboMode true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
transitive = true;
}
implementation 'com.android.support:multidex:1.0.2'
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:support-vector-drawable:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.github.bumptech.glide:glide:4.4.0'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.android.volley:volley:1.0.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.google.android.gms:play-services-base:11.8.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.android.gms:play-services:11.8.0'
implementation 'com.google.android.gms:play-services-auth:11.8.0'
implementation 'com.firebase:firebase-jobdispatcher:0.6.0'
implementation 'me.wangyuwei:ParticleView:1.0.4'
implementation 'com.devbrackets.android:exomedia:4.0.3'
implementation 'com.facebook.android:audience-network-sdk:4.27.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
My Master gradle is look like.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
classpath 'io.fabric.tools:gradle:1.+'
}
}
allprojects {
repositories {
maven { url 'https://maven.google.com' }
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Facebook Audience Network already includes a copy of exoplayer.
Replace
implementation 'com.facebook.android:audience-network-sdk:4.27.0'
by
implementation ('com.facebook.android:audience-network-sdk:4.27.0'){
exclude group: 'com.google.android.exoplayer'
}
and it should work.