• Work all day and sleep all night. You can live out your roughneck dreams as a lumberjack. Available for Android. Download Now!
  • Our very first game "The Shaft" is available exclusively on Android. Try this fun and addictive game for free. Download Now!
  • The Shaft is now available in an ad-free version. With no more annoying adverts or delays between plays. Buy Now!
  • Bakery Beats - The exciting new puzzle game by Maple Scot development. Colourful and addictive match-3 game with a difference. Try it today! Download Now!
  • They say you can't buy happiness. We say, they're wrong! Happiness is now just a click away. Enjoy relaxing imagery on your smarphone or tablet any time to drift away into a space of pure delight. Buy Now!
  • Prismatoids, geometric shapes made fun. Prismatoids is a new and exciting puzzle game from Maple Scot development with three addictive game modes to unlock, each with their own challange and strategies. Be sure not to miss it. Fruit Miner mode is our favourite! Download Now!
  • FunTime Cards for kids is a fun and educational way to keep your little ones entertained on long journeys or in the waiting room. No more "I'm Bored" ! Buy Now!
  • FunTime Brain Games is a fantastic little game to boost your little ones brain power. Start them small and the game grows with them. As they develop so will their ability to play the game. Download Now!
Joomla Vorlage by Jackets

Logger Bill - A Tour of the Tree (Part 3 - Fire OS Support)

Category: Articles Published: Sunday, 09 November 2014 Written by James Durie

Reasoning

One of the Issues with using the Google Play Games Services is that it requires the Google Play Games app be installed on the users device and that is only available on Google Play.

If you want to support Amazon Kindle Fire devices then you can't use Google Play. You could of course detect the presence of Google Play and just disable those features but I wanted to provide an alternative for Amazon users.

 

 

Game Circle

Amazon provides Game Circle as its system for online play and Leaderboard and Achievement tracking.

Its very similar to Google Play Games in many respects providing online Leaderboards, Achievements and data synchronisation.

 

GameCircleSDK

For obvious reasons I have not added the GameCircleSDK to the Logger Bill source tree. If you want to try it out you will need to do these steps after downloading the tree.

  • Go here and download the SDK from the link on that page
  • Copy the Android/GameCircle/GameCircleSDK contents to the GameCircleSDK directory in the Logger Bill tree
  • Copy the Android/Ads/lib/amazon-ads-5.4.146.jar to GameCircleSDK/libs in the Logger Bill tree
  • Add fire and GameCircleSDK to the settings.gradle file
  • Uncomment the fire and GameCircleSDK modules from the root build.gradle
  • Modify the GameCircleSDK/AndroidManifest.xml file and change the package to "com.amazon.ags.lib"

The reason for the last step is that the gradle android plugin will attempt to merge the manifests and there is a conflct with the one in the GameCircleSDK and the one in the game circle jar.

It isn't used since ours overrides it but we still need to remove the conflict for the build to complete.

Replacing the Google Play Games Services, Cloud Save and AdMob Ads with Amazon GameCircle, Whispersync and Amazon Ads was fairly straightforward as they are all pretty similar.

Amazon Developer Console

Go to the Amazon Developer Console and sign up and start setting up your game. Its a fairly simple process and Amazon has online guides to help you. You can also sign up for Amazon Ads here too.

If you do sign up for Ads you will have to fill in a tax status form. I'm in the UK so it was straightforward for me, YMMV.

You can also start adding GameCircle definitions in here. Its a similar process to that in the Play Developer Console except that instead of generating unique ids for you Game Circle expects you to enter them on the form. As google had already generated them for me I just re-used the ids from there. This simplified things immensely as I didn't have to change any code in the AchievementManager or LeaderboardManager.

When you do set this up its going to ask for the sigining key from your keystore just like Google Play does except Google Play asks for the SHA1 key and Amazon wants the MD5 key. To get the MD5 key you need to use keytool like this:

keytool -list -v -keystore debug.keystore

If you don't provide the -v then you wont get the MD5 key listed.

Do this twice once for your debug keystore and once for your prod keystore and both times save the resulting api_key.txt file. Store the debug file as fire/assets-raw/debug_api_key.txt and the prod file as fire/assets-raw/prod_api_key.txt the gradle build has tasks to copy the appropriate file to assets/api_key.txt when assembling the apk. If the file doesn't exist in the assets directoy Game Circle will not work.

Initialisation

First things first we have to initialise the api and you must do it from the OnResume method of your Android activity. This requires an object which implements the AmazonGamesCallback interface. I chose to keep this in a separate class but you don't have to.

This calls the onServiceReady method where you can then happily get instances of the support classes. I also chose to do the login at this point rather than give the user a button to click. This also makes it more similar to the Google Play interface.

Do be careful with this though as the login pops up a new activity and the OnResume is called again when the login page is dismissed. You can easily get in a to a cycle here.

Once logged in a similar set of functions are provided. Achievements can be incremented to a set percentage, this requires working out in the code unlike on Google Play where you provide the value required to make the achievement. If you want the achievement to be unlocked then just set the percentage to 100.

For Leaderboards you just submit a score as a long. Unlike Google Play, Game Circle doesn't understand that you might want decimals or a time value so you'll have to adjust it as necessary. It looks a bit hacky but it works!

Whispersync

 Whispersync works in a similar enouh way to Cloud Save that it can be manipulated to fit. It does in fact have a lot more functionality than cloud save but I chose to just do the most basic process which was store a blob of data and handle conflict resolution myself.

Ads

Like AdMob you will need to associate your Ads with your game. Amazon ads provides a unique app key for your game to use. Unlike AdMob you do not need to define what types of ad you will use in game. Banner ads do not automatically refresh like in AdMob so you will need to reload these every so often yourself. Interstitials work almost exactly the same. We have found that the best way to make them not too instrusive is to request an Ad at startup and attempt to show it only when you need it (for us thats every 5 plays). When you show the interstitial then request the next one. If it isn't available at the time you need then just don't show it.

Conclusion

All in all this was pretty easy to do and since it is just libraries works on pretty much any android device not just Kindle Fire devices.

Take a look at the Logger Bill page for links to "Logger Bill on Fire". The code has been added to the github repository and is available now.

Hope you find this useful and good luck with your future projects.

Hits: 5848