Search code examples
androidgradlelibgdxgoogle-play-servicesgoogle-play-games

Cannot Resolve import com.google.android.gms


I made a game with using Libgdx library. Now I want to add a leader board table to my game. For doing this I followed this tutorial : here

But in that tutorial I stuck at step 29. Because my imports doesn't resolved.

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;

For example , After I write import com.google.android.gms.games and write . , only two hints show up to me : R and *.

In sdk manager , Google Play Services has already installed.(I use Android Studio)

Also,It is my projects 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"

    }
}

What can I do for solve this problem?


Solution

  • you are lacking the play-services-base library:

    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"
    

    ... as well as, having added play-services-auth twice, for whatever reason. and also play-services:+ does not appear to be correct and therefore should also be removed. with the new versioning, one has to add these dependencies individually.