Google Play Games Services in libGDX

Google Play Games Services offers social leaderboards, achievements, and much more (realtime multiplayer, cloud saves, anti-piracy…)

Cross-platform features are deprecated, for new projects it is recommended to use on Android only.

Using open-source libGDX Extension

Google Play Games support for libGDX games on Android and Desktop is provided by gdx-gamesvcs libGDX extension. The extension also provides implementations for other game services (Apple Game Center, GameJolt and others).

Follow the readme and the project’s wiki to integrate GPGS and other game services in your project.

Manual integration in your project

The following article describes the manual integration in your project without using the library.

A Super Jumper based example that makes use of Leaderboards and Achievements is available to download from Google Play.

The project is freely available on GitHub, and a companion tutorial is available here.

Another in-depth LibGDX-based tutorial for adding Google Play Game Services can be found here.

Latest tutorial using Android Studio can be found here

IntelliJ IDEA and Android Studio Setup

  1. Install Google Play Service and Google Play Repository using and Android SDK To do that on Android Studio, Open up SDK Manager, ( Click the button next to the AVD manager in the top toolbar ) click Launch Standalone SDK Manager Scroll down to the Extras section and make sure these 2 packages are installed and updated to the latest :
    • Google Play services
    • Google Repository
  2. Download the BaseGameUtils sample project here, copy folder BaseGameUtils, located in folder BasicSamples into your project root folder.
  3. Edit settings.gradle
    include 'desktop', 'android', 'ios', 'html', 'core', "BaseGameUtils"
  4. Edit root build.gradle and add the below as android dependency:
    compile project(":BaseGameUtils")
  5. in your AndroidManifest.xml file
    • add two permissions:
       <uses-permission android:name="android.permission.INTERNET" />
       <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    • add to your application tag
       <meta-data android:name="" android:value="@string/app_id" />
  6. In your Android project, under ‘res’->’values’, in file strings.xml add app_id as follows, where 123456789 is your app ID as declared in the Google Play Developer Console:
    <?xml version="1.0" encoding="utf-8"?>
      <string name="app_name">sample_ios_google_signin</string>
      <string name="app_id">123456789</string>
  7. build.gradle in Android project

    Synchronize with Gradle. you will get the following message:

    Error:Execution failed for task ':android:processDebugManifest'.
    > Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 15 declared in library [libgdx-GPGS:BaseGameUtils:1.0]

    edit and set minSdkVersion to the version number in the message above (in this case ‘15’)

iOS integration

Google Play Game Services is no longer supported on iOS. You should use something like gdx-gamesvcs or Firebase instead.