How difficult is it to port a C++ game to Google Play using Android SDK (or Marmalade, etc)

1.5k Views Asked by At

I'm currently developing a game in C++/SFML and I understand that Google Play games are typically C or Java but it is possible to make an "app" (not necessarily a game??) for Google Play that is written in C++. I understand to do so you must use an Android SDK (i'm not exactly sure how an SDK works at this point in time) or a similar software such as Marmalade must be used in conjunction with the c++ code in order to make it run on Android. Two questions:

1) Are there elements of c++ code (such as pointers) that can not be ported to Google Play / Android using Android SDK?

2) How difficult is it to port c++ code to Google Play / Android with Android SDK or similar software?

Thanks in advance

2

There are 2 best solutions below

1
MuertoExcobito On BEST ANSWER

You can compile C++ on Android using the NDK.

As for SFML, it apparently isn't available for Android 'yet':

With SFML, your application can compile and run out of the box on the most common operating systems: Windows, Linux, Mac OS X and soon Android & iOS.With SFML, your application can compile and run out of the box on the most common operating systems: Windows, Linux, Mac OS X and soon Android & iOS.

As for how hard it will be to port - obviously it's an opinion, but in my experience Android native development is considerably more difficult than Android JavaVM or desktop development.

3
Roy Falk On

I won't talk about SFML, as I haven't heard about it and will focus on the C++ aspect. I write native iOS and Android for a living. In this context, it means Java using Android SDK and Objective C for iOS.

Having worked on two projects, it's quite easy to port the business logic and classes from one to the other. I haven't touched C++ in quite a few years, but unless you're doing something really funky with multiple inheritance, the coding itself will be straightforward.

Where I encountered difficulty (and you will even more) is the GUI side of things. If you're coming from PC coding, your GUI code will need to be overhauled extensively. One exception is web GUI with responsive design, but that opens a whole lot of other problems such as no native APIs and limited capabilities.

Regarding NDK, you need to understand that this is true low level code, written in machine language. This means you don't enjoy the write once, run anywhere of Java and need to compile for both ARM and Intel devices. Intel has been traditionally weak in this market but I wouldn't bet against them.

For iOS it means XCode will generate duplicate code for ARMv7, ARMv7s, ARM64 (and IA-64 for the simulator). This can't be helped anyhow.

One alternative is to go true web app. Ditch this legacy C++ and go HTML and JavaScript. If you port your game to web, you'll be able to run it everywhere. Both iOS (UIWebView) and Android (WebView) support a web container. Of course, that will come with the new and exciting framework of the week.