Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 366
tayfur cangebes Avatar asked Feb 16 '26 03:02

tayfur cangebes


2 Answers

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.

like image 104
Martin Zeitler Avatar answered Feb 17 '26 17:02

Martin Zeitler


  1. Open the build.gradle file inside your application module directory.
  2. Add a new build rule under dependencies for the latest version of play-services.
  3. Ensure that your top-level build.gradle contains a reference to the google() repo or to maven { url "https://maven.google.com" }.
  4. Save the changes, and click Sync Project with Gradle Files in the toolbar.

enter image description here

like image 42
Stack Fox Avatar answered Feb 17 '26 17:02

Stack Fox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!