Category Archives: Android

Cross Platform Development

The last 2 years of writing has been primarily focused on making games with Monkey-X. While I will continue to make games, the focus of my writing will be changing a little.

Last fall as I was getting ready to try to release games to mobile, I built my first Android app. It is a little rental property cashflow estimation calculator and I had a lot of fun making it and figuring out some of the Android development basics. But I didn’t write about it because the focus of this blog was about making games.

This is going to change.

New Focus

I am a web developer by day, and one of the reasons I like the web and web development is because you can write an application one time and as long as someone has a web browser they can use it. Not only that, but most of the logic can be kept on your server so you are really in charge of the environment the code is hosted in. Client heavy web apps using various Javascript libraries have changed some of this but for the most part it is true. And it has gotten even better as web browsers are converging better on standards.

One of my strong dislikes is having to do the same work twice. If I can find a way to do it only once I will. If I can build a system that does it for me so I never have to do it again I will.

This is one of the reasons I chose Monkey-X as I started making games. It deploys cross platform. Whether you want to put it on the web, on a phone, or on the desktop you can write your game logic in a single code base with usually some small tweaks per platform. The basic game logic remains the same.

Starting this month I will be adjusting the overall focus of the blog to cross platform development in general, no longer just games. The primary focus will be on the Xamarin platform.

Xamarin

Xamarin is a company and the name of their framework or toolset. It is a .NET based framework for allowing you to write apps that share as much code as possible between Windows 10, iOS, and Android.

Microsoft bought Xamarin last year (2016) and at time of this writing it is free for solo developers to get started with them.

The reason I am choosing it is the same reason I chose Monkey-X. Giving me the ability to write something once and then use that multiple times is exactly what I am looking for. And I want to create apps that work well on the phone. Their are some hybrid web solutions using things like Cordova where you write your app in Javascript, HTML, CSS and build it for the phone but that is not what I am looking for right now.

Bonus, Xamarin has a platform for making games with it called CocosSharp (part of the Cocos2D family) that I may utilize.

So look for coming updates on making cross platform apps and games.

Guide to Building a Monkey-X Game to Android

Step 1: Import the project to Android Studio

You will need to import the project to Android Studio as a Eclipse project. File – New – Import Project and select the folder with your Monkey-X android build. This is usually ../appname/main.buildv86e/android_new although your main.build folder may be named differently depending on which version of Monkey you are compiling against.

Step 2: Rename the package

The default package name is “com.monkeycoder.monkeygame”. This must be renamed as that is already taken on the Play store.

You will need to rename this in the Android Manifest, the main Java file, the res – layout – main.xml file, and the gradle build script. In the Java file you will need to rename the package at the top as well as the ANDROID_APP_PACKAGE variable (constant?).

I also recommend renaming the application and activity labels in your AndroidManifest.xml file from “Monkey Game” to your games title.

Step 3: Create an Icon

You will need to bring in your own icon for the app. This needs to be brought into the “res” folder and then referenced from the AndroidManifest.xml file.

Simply do a File – New – Image Asset and select the file you want to import. Android studio will generate various resolution versions of it for you.

I believe you will want at least a 512×512 pixel image. It kills 2 birds with one stone because Android will use it for the icon and 512×512 is the resolution needed to upload your icon to the Play store page.

Step 4: Test it on an actual device

After doing these steps, sometimes you miss something and the app will crash. Make sure to test your Android Studio build on an actual device now.

Step 5: Create a Signed APK

You will need to create a Signed APK file to upload. Android Studio makes this pretty easy. If you don’t have a key or a keystore already, it will walk you through setting one up. Then use the key to create a Signed build of your game that will be used to publish.

Step 6: Fill out information on Google Play and Upload the Signed APK

You now need to go through all of the questions and info for the Google Play store. This includes uploading your icon as well as a feature image that at time of this writing is 1024×500 pixels. You can put whatever you want here but probably should make it related to your game. Additionally it asks for screenshots. Most phones can do this although it could be difficult with an action game, or you could do it with an emulator.

There is also an area to put a link to a youtube video if you want to cut a short promotional video for your game.

Other steps include filling out a content rating questionnaire, linking to a privacy policy, and setting up purchases and adds (to name a few).

Quick and Dirty

This is a brief overview of the whole process. Mostly just notes to myself with reminders about changing things in Android Studio for the next time I release a game like this.

Hope you find this helpful.