Is it possible to compile an android game for pc desktop?

| | August 5, 2015

If I have an android game based on java native libraries. Is it to possible to compile into a windows/linux executable without a 3rd party emulator?

2 Responses to “Is it possible to compile an android game for pc desktop?”

  1. No, you cannot directly compile an Android project into a non-Android based executable.

    You’re going to need to port the code out. How easy that will be is going to depend greatly on how you structured your code base. If the game/application logic is separate to that of your Android specific code (think Activities, etc), it should be fairly easy to do, because that’s the code that will obviously need to be re-written.

    I would take a look at LibGDX to aid this. If you port your game using LibGDX, you’ll have both desktop and Android with virtually the same code base.

  2. The short, official answer is no, you can’t. Android has it’s own specific API’s which don’t exist for any desktop environment.

    That being said, there’s things you can do:

    • Most of the Android Java API is the same as that of the desktop JDK. So for some application, migrating them for the desktop could mean simply grabbing the code, building it with the JDK, and maybe just change a small part of the code (like UI stuff, and OpenGL APIs etc). I’ve actually done this, and manually replaced the Android Java UI code with Desktop Java Swing code by hand, and it was fairly painless

    • finally there’s the Android x86 project which lets you run an Android environment on a desktop machine (like a virtual machine, it’s actually built as a VirtualBox machine). Using this you can deploy and run your Android app on a desktop. There are limitations, like the fact that the latest version of Android will take some time before being ported to Android x86.

Leave a Reply