Search code examples
javaandroidlibgdxfacebook-android-sdk

libGdx and facebook


I'm testing facebook login with libgdx project. In my project-level build.gradle file, I added the gdx-facebook dependency from here

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        ......
        ......
        compile "de.tomgrill.gdxfacebook:gdx-facebook-android:1.4.1"
    }
}

and added the following dependency in the Module:android build.gradle file.

dependencies {
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}

There is no error in such condition. But when I remove tomgrill dependency from project-build.gradle file, android studio show me the following alert and the project cannot run.

Gradle project sync failed. Basic functionality(e.g. editing, debugging) will not work properly.

Why facebook dependency does not work without tomgrill gdx-facebook extension? What the problem is?


Solution

  • Artifact facebook-android-sdk available in mavenCentral repository so you've to add mavenCentral() in your project repositories list in root build.gradle file.

    By default, In LibGDX projects mavenCentral() is in repo list.

    Some transitive dependency in your project, Internally facebook-android-sdk using many support library like annotations, customtabs, appcompat-v7, support-v4 and more..

    These support libraries are available on Google's Maven repository so you need to include Google's Maven repository in your top-level build.gradle file :

    allprojects {
        repositories {
            google()
    
            // If you're using a version of Gradle lower than 4.1, you must instead use:
            // maven {
            //     url 'https://maven.google.com'
            // }
            // An alternative URL is 'https://dl.google.com/dl/android/maven2/'
        }
    }