android - 无法合并 dex - 当我使用 Facebook Audience Network SDK 时

标签 android facebook gradle android-multidex

我在使用 Facebook Audience Network SDK 时收到此错误。

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

我的应用程序级别 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'

我的 Master gradle 看起来像。

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 已包含 exoplayer 的副本。

替换

implementation 'com.facebook.android:audience-network-sdk:4.27.0'

implementation ('com.facebook.android:audience-network-sdk:4.27.0'){
    exclude group: 'com.google.android.exoplayer'
}

它应该可以工作。

关于android - 无法合并 dex - 当我使用 Facebook Audience Network SDK 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48356840/

相关文章:

android - 自定义 View 扩展 View 类但仍然基于 XML 布局

android - 解释不同的导航类型,Android

java - 如何使用 firebase 监听 android studio 中的变化

iphone - 为单个设备上的多个用户自动重新授权 Facebook

android-studio - 如何在android studio中依次运行几个命令行?

android - 在 Android Studio 中使用 Gradle 添加 Wire 依赖项的最佳方法

android - 无法从本地主机外部连接到模拟器内的服务器

facebook - 错误 : (#3501) User is already associated to the object type, 文章,关于独特的操作类型 Like。原始操作 ID:10202808015141547

facebook - 有没有办法获取特定城市的所有 Facebook 事件?

java - Gradle说Java Home在macOS Catalina中有所不同