Duplicate class error when i added facebook login and SDK dependencies

Viewed 1201

I added "Login with facebook" feature on my app and also i added these 2 dependencies on my project:

implementation 'com.facebook.android:facebook-login:5.15.3'
implementation 'com.facebook.android:facebook-android-sdk:5.15

The problem is whenever i try to run my app on my device i'm getting this error below:

Duplicate class android.support.customtabs.ICustomTabsCallback found in modules browser-1.0.0-runtime (androidx.browser:browser:1.0.0) and customtabs-27.0.2-runtime (com.android.support:customtabs:27.0.2)
Duplicate class android.support.customtabs.ICustomTabsCallback$Stub found in modules browser-1.0.0-runtime (androidx.browser:browser:1.0.0) and customtabs-27.0.2-runtime (com.android.support:customtabs:27.0.2)
Duplicate class android.support.customtabs.ICustomTabsCallback$Stub$Proxy found in modules browser-1.0.0-runtime (androidx.browser:browser:1.0.0) and customtabs-27.0.2-runtime (com.android.support:customtabs:27.0.2)
Duplicate class android.support.customtabs.ICustomTabsService found in modules browser-1.0.0-runtime (androidx.browser:browser:1.0.0) and customtabs-27.0.2-runtime (com.android.support:customtabs:27.0.2)
Duplicate class android.support.customtabs.ICustomTabsService$Stub found in modules browser-1.0.0-runtime (androidx.browser:browser:1.0.0) and customtabs-27.0.2-runtime (com.android.support:customtabs:27.0.2)
Duplicate class android.support.customtabs.ICustomTabsService$Stub$Proxy found in modules browser-1.0.0-runtime (androidx.browser:browser:1.0.0) and customtabs-27.0.2-runtime (com.android.support:customtabs:27.0.2)
Duplicate class android.support.customtabs.IPostMessageService found in modules browser-1.0.0-runtime (androidx.browser:browser:1.0.0) and customtabs-27.0.2-runtime (com.android.support:customtabs:27.0.2)
Duplicate class android.support.customtabs.IPostMessageService$Stub found in modules browser-1.0.0-runtime (androidx.browser:browser:1.0.0) and customtabs-27.0.2-runtime (com.android.support:customtabs:27.0.2)
Duplicate class android.support.customtabs.IPostMessageService$Stub$Proxy found in modules browser-1.0.0-runtime (androidx.browser:browser:1.0.0) and customtabs-27.0.2-runtime (com.android.support:customtabs:27.0.2)
Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.0.2-runtime (com.android.support:support-compat:27.0.2)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.0.2-runtime (com.android.support:support-compat:27.0.2)
Duplicate class android.support.v4.app.INotificationSideChannel$Stub$Proxy found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.0.2-runtime (com.android.support:support-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$CallbackHandler found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$ConnectionCallback found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$ConnectionCallback$ConnectionCallbackInternal found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$ConnectionCallback$StubApi21 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$CustomActionCallback found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$CustomActionResultReceiver found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$ItemCallback found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$ItemCallback$StubApi23 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$ItemReceiver found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImpl found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$1 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$2 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$3 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$4 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$5 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$6 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi21$7 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi23 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplApi26 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$1 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$2 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$3 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$4 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$5 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$6 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$MediaServiceConnection found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$MediaServiceConnection$1 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserImplBase$MediaServiceConnection$2 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaBrowserServiceCallbackImpl found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaItem found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaItem$1 found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$MediaItem$Flags found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$SearchCallback found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$SearchResultReceiver found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$ServiceBinderWrapper found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.media.MediaBrowserCompat$Subscription found in modules media-1.0.0-runtime (androidx.media:media:1.0.0) and support-media-compat-27.0.2-runtime (com.android.support:support-media-compat:27.0.2)
Duplicate class android.support.v4.os.ResultReceiver$MyRunnable found in modules core-1.3.1-runtime (androidx.core:core:1.3.1) and support-compat-27.0.2-runtime (com.android.support:support-compat:27.0.2)

Go to the documentation to learn how to Fix dependency resolution errors.

My build.gradle file:

plugins {
    id 'com.android.application'
    id 'com.google.gms.google-services'

}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.george.igrow"
        minSdkVersion 27
        targetSdkVersion 30
        versionCode 5
        versionName "0.5"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation platform('com.google.firebase:firebase-bom:26.7.0')
    implementation 'com.facebook.android:facebook-login:5.15.3'
    //implementation 'com.facebook.android:facebook-android-sdk:5.15.3'
    implementation 'com.android.billingclient:billing:3.0.3'
    implementation 'com.daimajia.androidanimations:library:2.4@aar'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'com.google.firebase:firebase-auth:20.0.4'
    implementation 'org.jetbrains:annotations:15.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.firebase:firebase-database:19.7.0'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

I try to remove the 2 dependencies and then i'm getting other errors

NOTE: I have androidx on my project

3 Answers

Try to update the version, it helped me

implementation 'com.facebook.android:facebook-android-sdk:9.1.1'

You only need to add this in your build.gradle(Project):

buildscript{
    repositories {
        jcenter()
    }
}

And the following code in you build.gradle(Module:app):

dependencies {
     implementation 'com.facebook.android:facebook-android-sdk:5.0.0'
}

Here is the source how to set an Facebook Login properly. Good luck! :) Hope your question is answered!

You can't use android support libraries along side androidx libraries

Related