My experience porting SpaceShooterX from Windows Phone to Android using Xamarin
So this is it, I am about to publish SpaceShooterX for Android to Google Play. It took me about three weeks to port it from Windows Phone to Android using Xamarin.
Since this is my first port, most of the time was spent learning the differences between those two platforms although I’ve had experienced developing apps for Android before (using Basic4android) so this wasn’t that hard.
Another thing was finding ways to implement platform specific functions such as In App Billing, data storage, user interface etc.
Overall, I’d like to share a few things I’ve learned from this project.
Code reuse is high, above 90% which I am very happy with.
There are not as many discussions or sources for Xamarin specific help as compare to that when developing for Windows Phone. I’ve to dig around StackOverflow, refer to Android documentation and try to convert codes to their c# equivalent, Xamarin forum, and Monogame.net.
I encountered more issues when working with Monogame for Android. In Windows Phone, everything appears to ‘just work’. Perhaps this has to do with how Android handles things differently internally.
For instance, when using the SoundEffect class, it was supposed to be fire and forget but I kept getting the InstancePlayLimitException. However, once I understood that this class creates SoundEffectInstance objects internally which lead to memory leaks, I just re-wrote my class to use the SoundEffectInstance class directly and manage the objects manually.
Performance wise, I do not notice much difference after porting to Android. I tested SpaceShooterX on Lenovo A359i, a dual core, 512MB device and the game run as smoothly. That’s after I fixed the SoundEffect issue above.
Nevertheless, I’m incline to believe Windows Phones are more efficient in garbage collection. It also feels more optimised albeit still lacking useful features common in Android or IOS.
I have to update my Monogame copy from 3.2 to 3.3 due to the black screen bug when resuming the game after pressing the home button. This unfortunately ‘broke’ my Portable Class Library which depends on the Monogame Portable assembly as I also have to use the full version of Monogame assembly for that library.
The final APK file size increased from 31MB for Windows Phone to 45MB for Android, that’s a whooping 45% increased! I tried XamGuard to reduce the size but my several attempts had failed and not wanting to mess with my code further, I decided to not use it for now.
Even with such increase, I think using Xamarin is still worth it as I could use the same code base to port SpaceShooterX to IOS later without much hassle.
There are so many info, data, options, stats in Google Play Developer Console which is a joy to dive into as compare to the understandably limited Windows Phone dashboard in Dev Center.
I have to sign my apk manually using the Java JDK version 1.6.0_45 as Xamarin Studio uses the latest version in the signing process which resulted the “app not installed” or “application not installed” error in some Android devices.
As for monetisation, for a start I’m using Admob banner only. I’ll see how it’ll perform before I explore other options. I feel that there’s probably not many ad-provider libraries available for integration in Xamarin for Android, but correct me if I am wrong.
Filling up the product details in the developer console was as easy as copying and pasting the text from my Windows Phone dashboard. I can reuse my existing screenshots as Google does not require specific dimensions as long as the minimum length for any side is 320px and the maximum length for any side is 3840px.
I also feel that there are greater opportunity for me to promote my app as there are more review sites, YouTubers and advertising companies that support the Android ecosystem. But I am also aware that they are a lot more competition.
I will let you guys know how SpaceShooterX perform in the android ecosystem in my future posts. So if you want to be kept updated, feel free to subscribe to this blog!
Download SpaceShooterX for Android in Google Play here.