android - 无法解析导入 com.google.android.gms

标签 android gradle libgdx google-play-services google-play-games

我使用 Libgdx 库制作了一个游戏。现在我想在我的游戏中添加一个排行榜表。为此,我遵循了本教程:here

但在那篇教程中,我停留在第 29 步。因为我的导入没有解析。

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.games.Games;
import com.google.android.gms.games.Games.GamesOptions;
import com.google.android.gms.games.GamesActivityResultCodes;
import com.google.android.gms.games.multiplayer.Invitation;
import com.google.android.gms.games.multiplayer.Multiplayer;
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch;
import com.google.android.gms.games.request.GameRequest;
import com.google.android.gms.plus.Plus;
import com.google.android.gms.plus.Plus.PlusOptions;

例如,在我写完 import com.google.android.gms.games. 之后,只有两个提示出现在我面前:R*

在 sdk manager 中,已经安装了 Google Play 服务。(我使用的是 Android Studio)

此外,这是我的项目 build.gradle for Android :

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

    configurations { natives }

    dependencies {
        compile "com.google.android.gms:play-services-games:15.0.1"// I think this line should solve all imports problem, but it can't
        compile "com.google.android.gms:play-services-auth:16.0.0"
        compile "com.google.android.gms:play-services-auth:11.6.0"
        compile 'com.google.android.gms:play-services:+'

        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"

    }
}

我能做些什么来解决这个问题?

最佳答案

您缺少 play-services-base 库:

implementation "com.google.android.gms:play-services-base:17.5.0"
implementation "com.google.android.gms:play-services-auth:19.0.0"
implementation "com.google.android.gms:play-services-games:21.0.0"

...以及,无论出于何种原因,添加了两次 play-services-auth。并且 play-services:+ 似乎不正确,因此也应该删除。使用新的版本控制,必须单独添加这些依赖项。

关于android - 无法解析导入 com.google.android.gms,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52210539/

相关文章:

java - 如何通过 Gradle 将 ojdbc7 添加到 Java Web 应用程序?

android - 世界您好,libgdx 在手机上崩溃

java - HTTP 请求处理程序连接重置错误

java - Android setVisibility View.INVISIBLE 和 View.GONE 不工作

Android - 亚马逊应用内购买

android - 如何设置Navigation Drawer从右向左打开?

linux - Gradle 1.3 : build. gradle 不构建类

java - 将 AdView 移至底部,Cocos2dx Activity

java - 是否有用于提取Minecraft配方的工具/API?

java - 使用 libgdx 写入 json 文件