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

问题描述 投票:1回答:1

我使用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经理中,已经安装了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"

    }
}

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

android android-studio libgdx google-play-services google-play-games
1个回答
2
投票

你缺少play-services-base图书馆:

compile "com.google.android.gms:play-services-base:15.0.1"
compile "com.google.android.gms:play-services-auth:16.0.0"
compile "com.google.android.gms:play-services-games:15.0.1"

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


1
投票
  1. 打开应用程序模块目录中的build.gradle文件。
  2. 在依赖项下为最新版本的play-services添加新的构建规则。
  3. 确保您的顶级build.gradle包含对google()repo或maven {url“https://maven.google.com”}的引用。
  4. 保存更改,然后单击工具栏中的“使用Gradle文件同步项目”。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.