2

I am trying to implement facebook sdk according to this, https://developers.facebook.com/docs/audience-network/android

When I trying to compile it im getting this error.

Error: Program type already present: com.facebook.ads.Ad

I'm using android studio 3.2.1

this is my gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId "com.test.test"
        minSdkVersion 16
        targetSdkVersion 27
        multiDexEnabled true


        ndk {
            moduleName "player_shared"
        }
    }

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

    dexOptions {
        javaMaxHeapSize "4g"
    }
}

dependencies {
    implementation 'com.google.android.gms:play-services:+'
    implementation 'com.android.support:multidex:1.0.3'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.google.android.gms:play-services-ads:11.6.0'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
    implementation 'com.facebook.android:facebook-core:[4,5)'
    implementation 'com.facebook.android:facebook-marketing:[4,5)'
    implementation 'com.android.support:recyclerview-v7:25.3.1' // Required Dependency by Audience Network SDK
    implementation 'com.facebook.android:audience-network-sdk:5.+'
    // More deps here //
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Hi Im Naru7o
  • 72
  • 2
  • 12
  • 1
    Please post your app-level `build.gradle`. – Jay Nov 14 '18 at 08:37
  • Okay. done. I just added it – Hi Im Naru7o Nov 14 '18 at 08:41
  • Duplicate of https://stackoverflow.com/questions/49537914/build-failed-program-type-already-present-com-facebook-ads-ad – GoRo Nov 14 '18 at 08:43
  • I am sorry. I didn't find any answer there :( and that was 7 months ago. – Hi Im Naru7o Nov 14 '18 at 08:45
  • 1
    As you can see [here -- the structure of facebook SDK](https://github.com/facebook/facebook-android-sdk), you have duplicate APIs since you're trying to use SDK and core together. Remove `implementation 'com.facebook.android:facebook-core:[4,5)'` and rebuild. – Jay Nov 14 '18 at 08:46
  • thank you very much jay. it's working. but will that be a problem to my facebook analytics ? they said to add it in before. – Hi Im Naru7o Nov 14 '18 at 08:50
  • No, that won't be a problem. – Jay Nov 14 '18 at 08:57
  • @HiImNaru7o just small addition, use always same version of appcompat-v7 and recyclerview-v7. – Yuriy Nov 19 '18 at 01:05

0 Answers0