-
Notifications
You must be signed in to change notification settings - Fork 6
Google Play Games Extension v1.0.2
Google site links: https://developers.google.com/games/services/ - contains all the Google documentation.
The extension is built against Google Play Services revision 7 and the BaseGameActivity class from the Android samples dated April 18th 2013. Using Marmalade 6.2.2. GooglePlayGames and requires a minimum of Android SDK 13 (Android 3.2 Honeycomb).
The extension only supports Leaderboards and Achievements at this time, though adding more functionality should be easy enough.
I have included a buildable sample including keys – however only Google Plus accounts whitelisted in my console will be able to interact with it. You will need to change the settings and configure your own application. You can use my private keys for convenience if you prefer though must replace with your own if releasing,.
Any problems please email me – [email protected] .(It was a bit of a pig to get working as you may be able to tell from the length of the instructions below – apologies in advance I hope the process will be more streamlined in the future)
- You need to configure your app on the website first, detailed instructions are in the Google documentation https://developers.google.com/games/services.
- You need to generate authorisationyou’re your app https://developers.google.com/games/services/console/enabling#step_3_generate_an_oauth_20_client_id. Some additional reading below.
- I have included keys I generated in ExampleApplication/Keys – feel free to re-use them though you should use your own keys on release product.
- 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. (I think this is now fixed).
- 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 mine temporarily.
- 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 my 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.
- I have included a pyc hotfix from Marmalade in the ExampleApplication folder. 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 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 + account won’t be in my 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 site.
- Edit res/values/ids.xml and change the app_id to the one in the Google site. 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. Eg. 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 – my apologies for this as I tried hard to avoid it, however it was unavoidable. 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 Games --> <uses-sdk android:minSdkVersion="13" android:targetSdkVersion="17" /> <!-- Required for Google Play Games -->
-
To the section add
<!-- Required for Google Play Games --> <meta-data android:name="com.google.android.gms.games.APP_ID" android:value= "@string/app_id" /> <!-- Required for Google Play Games -->
-
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. Eg. 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
-
If you need to update 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,
- Copy the included android.pyc file into Marmalade/6.2/s3e/deploy/plugins/android (backing up the original).
- In the same Marmalade folder replace the aapt.exe with an up to date version from your adt folder (sdk\platform-tools).