Skip to content
Tim Closs edited this page Jun 4, 2013 · 3 revisions

This is a Marmalade extension that implements an Android interface to Google Play game services.

Google site links: https://developers.google.com/games/services/

The extension is built against Google Play game services revision 7 and the BaseGameActivity class from the Android samples dated April 18th 2013, and using Marmalade SDK 6.2.2. It requires a minimum of Android SDK 13 (Android 3.2 Honeycomb).

The extension only supports Leaderboards and Achievements at this time. Adding additional functionality should be straightforward.

The extension includes a buildable sample including keys. You will need to change these settings and configure your own application. You can use these private keys for convenience if you prefer, although they must be replaced with your own before publishing.

For technical support, please use the GitHub Issues system, or email [email protected] .

Instructions:

In the Google Console:

  • You need to configure your app in the Google Play developer dashboard first. Detailed instructions are in the Google documentation https://developers.google.com/games/services.
  • You need to generate authorisation IDs for your app, as detailed here: https://developers.google.com/games/services/console/enabling#step_3_generate_an_oauth_20_client_id.
  • The extension includes private keys in ExampleApplication/Keys – feel free to re-use them, but you must changes these to your own keys before publishing.
  • If you get a blank dialog when generating the oauth, go to http://code.google.com/apis/console, select the game and agree to any terms of service.
  • If you already have a signing keystore you need to generate the SHA1 fingerprint from it. If you don’t have one and are simply letting Marmalade sign using its default keys you will need to make your own or use the private keys within the extension (for temporary use only!).
  • Get the SHA1 from your keystore using keytool -exportcert -alias androiddebugkey -keystore -list -v > file.sha
  • Copy the SHA1: section into the oAuth section when you configure your game – or copy it out of ExampleApplication/Keys/ s3eGooglePlayGames.keystore.sha file.
  • Make sure your Google account is upgraded to Google Plus.
  • Add your Google account as a tester.
  • At this time the extension only supports Leaderboards and Achievements.

Marmalade:

  • I have included a pyc hotfix from Marmalade in the ExampleApplication folder. If using Marmalade SDK 6.2.2, this is required in order for the Deploy to work. It contains a fix from Marmalade when running aapt to allow the Google res/ hierarchy to be added to your game. It adds the -auto-add-overlay command switch. This should be included by Marmalade in future versions so check the version I built against at the top of this file against the version you’re using – you shouldn’t need to apply the hotfix if yours is newer. To apply the aapt.exe hotfix copy the /ExampleApplication/android.pyc file into your Marmalade/6.2/s3e/deploy/plugins/android folder – overwrite the copy in there.
  • In the same Marmalade folder Marmalade/6.2/s3e/deploy/plugins/android replace the aapt.exe with an up to date version from your adt folder adt-bundle-windows-x86_64\sdk\platform-tools. This is needed to handle the transparent PNG files Google Play game services requires.
  • Hint: If you’re still getting issues during deploy – edit Marmalade\6.2\tools\DeployTool\Deploy.py and comment in the args.append("--verbose") line to get more logging info.
  • I’ve written a Marmalade example application that uses the extension in /ExampleApplication. You can build and run it – however will be unable to connect to the service as your Google Plus account won’t be in the correct whitelist. Modify it as follows if you want to get it running before modifying your code.
  • In the deploy tool under the Advanced Android settings set Android Package Name to the one you set up on the Google Play developer dashboard.
  • Edit res/values/ids.xml and change the app_id to the one in the Google Play developer dashboard. This is the long number you will see at the top of the page when you select your game on the site. Eg. 1081433154825
  • Modify the s3eGooglePlayGamesExample.cpp file.
  • Change the identifier for the Leaderboards and Achievements to the ones in your game. To be clear these are not the names you give them but the ID code you see after creating them in the list. For example CgkIicrB07wfEAIQBw
  • The example supports two Achievements and 1 Leaderboard.

When integrating with your own project you will need to do the following:

  • The extension needs to extend the Marmalade loader activity. This should not present a problem unless you are already extending the LoaderActivity due to some other extension. If this is the case you will need to merge the extensions.

  • Assuming this isn’t the case it simply a matter of setting the Custom Activity field in the Advanced Android settings of the Deploy tool to com.ideaworks3d.marmalade.s3egoogleplaygames.s3eGooglePlayGamesActivity

  • In the Deploy tool set the Application Keystore, Keystore Password, Key Alias Name and Private Key passwords to your keystore. You have to do this for both debug and release builds as the Google Play service should have the SHA1 fingerprint of the key and will silently refuse connections if the wrong key (or no key) is used to sign the App. See the deploy settings (or mkb) for the example app if you want to use my keystore.

  • Make sure your app has an AndroidManifest.xml – if it doesn’t, then copy the one from Marmalade\6.2\s3e\deploy\plugins\android into your project folder.

  • Modify AndroidManifest.xml –

  • To the section add …

                  <!-- Required for Google Play game services -->
                      <uses-sdk
                                android:minSdkVersion="13"
                                android:targetSdkVersion="17" /> 
                  <!-- Required for Google Play game services -->
    
  • To the section add

                  <!-- Required for Google Play game services -->
                                 <meta-data android:name="com.google.android.gms.games.APP_ID"
                                 android:value= "@string/app_id" />
                  <!-- Required for Google Play game services -->
    
  • Make sure Deploy is using your AndroidManifest.xml – Android -> Advanced -> Android Manifest.

  • Copy the /res folder from the ExampleApplication into your project and modify the ids.xml file. Replace the app_id with the one from the site. This is the long number you will see at the top of the page when you select your game on the site. For example 1081433154825. (this is the string referenced in the changes above to the Android Manifest)

  • Finally, copy this folder into your project path and add the relative path to the extension mkf file to your main mkb. For instance

                      subprojects
                     {
                             ../GooglePlayExtension/s3eGooglePlayGames.mkf
                     }
    
  • See the example app and the /h/s3eGooglePlayGames.h for documentation on how to use it.

Notes for updating the extension:

  • Copy the new jar into lib/android.
  • Copy the res/ folder into lib/android/
  • Import play services lib into Eclipse and copy the gen/R.java into source/android/
  • Run s3eGooglePlayGames_android_java.mkb

Note:

If you get aapt.exe errors during deploy,

  1. Copy the included android.pyc file into Marmalade/6.2/s3e/deploy/plugins/android (backing up the original).
  2. In the same Marmalade folder replace the aapt.exe with an up to date version from your adt folder (sdk\platform-tools).