Search code examples
javaandroidfacebookandroid-gradle-pluginfacebook-android-sdk

Error after adding Facebook login dependency in Android


I want to integrate my app with facebook login, but when adding below dependency and syncing Gradle:

implementation 'com.facebook.android:facebook-android-sdk:[5,6)'

I got the following errors:

ERROR: Failed to resolve: legacy-support-v4
Affected Modules: app


ERROR: Failed to resolve: browser
Affected Modules: app


ERROR: Failed to resolve: legacy-support-core-utils
Affected Modules: app


ERROR: Failed to resolve: media
Affected Modules: app

My build.gradle in app-level:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
}

repositories { }

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.***************"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.1'
    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
    implementation 'com.github.GrenderG:Toasty:1.4.1'
    implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
    implementation 'com.gauravk.bubblenavigation:bubblenavigation:1.0.7'
    implementation 'com.tuyenmonkey:mkloader:1.4.0'
    implementation 'me.riddhimanadib.form-master:form-master:1.1.0'
    implementation 'com.facebook.android:facebook-android-sdk:[5,6)'

}

apply plugin: 'com.google.gms.google-services'

and build.gradle on project-level:

buildscript {
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'io.fabric.tools:gradle:1.31.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://www.jitpack.io" }
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

I've searched a lot on google and StackOverflow and tested all the methods, but this problem doesn't fix. Please help me where is my problem.


Solution

  • I've tested some of Facebook SDK versions, suddenly in 4.26.0 version, my Gradle was successfully built. I've checked the release note of Facebook SDK on the next version ( 4.27.0 ) and I find this:

    Modified
    + Restructured the Facebook SDK and organized it into separate libraries/modules that can depend on one another.
    + Moves GraphRequest.createOpenGraphObject(ShareOpenGraphObject) to ShareGraphRequest.createOpenGraphObject(ShareOpenGraphObject)
    + Moves FacebookSDK.[set|get]WebDialogTheme(...) to WebDialog.[set|get]WebDialogTheme(...)
    + Removes unused dimens from styles.xml
    + Removes files only used by internal tests
    + updates proguard files

    Anyway, with the following line, my problem was solved:

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

    It's not good news for me to use about 3 years ago package, but at this point, I don't have any Idea.