libGdx 和脸书

libGdx and facebook

我正在使用 libgdx 项目测试 facebook 登录。在我的项目级 build.gradle 文件中,我添加了来自 here

的 gdx-facebook 依赖项
project(":android") {
    apply plugin: "android"

    configurations { natives }

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

并在 Module:android build.gradle 文件中添加了以下依赖项。

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

这种情况下没有错误。但是当我从项目-build.gradle 文件中删除 tomgrill 依赖项时,android studio 向我显示以下警报并且项目无法 运行.

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

如果没有 tomgrill gdx-facebook 扩展,为什么 facebook 依赖项不起作用?问题是什么?

工件 facebook-android-sdkmavenCentral 存储库中可用,因此您必须在根 build.gradle 文件的项目存储库列表中添加 mavenCentral()

默认情况下,在 LibGDX 个项目中 mavenCentral() 在 repo 列表中。

项目中的一些传递依赖,在内部 facebook-android-sdk 使用许多支持库,如 annotationscustomtabsappcompat-v7support-v4 等。

这些支持库在 Google 的 Maven 存储库中可用,因此您需要在顶级 build.gradle 文件中包含 Google 的 Maven 存储库:

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/'
    }
}