Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
Port the whole thing to libGDX, that should do the trick :) –  Nick Wiggill Dec 4 '12 at 13:27
Or Haxe/NME, or cocos2d-x, or a few other cross-platform libraries... :) –  Liosan Dec 4 '12 at 14:50
add comment

2 Answers

up vote 5 down vote accepted

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.

share|improve this answer
Will take a look on it. Thanks. –  petervaz Dec 4 '12 at 14:19
+1 You're right LibGDX lets you do just that, forgot about it. On the same page there's also Unity 3D, which does more or less the same thing, but is not free (and in fact, with the Android add-on I believe it becomes kindda pricey). –  Shivan Dragon Dec 4 '12 at 16:17
Yep, Unity is a good alternative but I would only recommend that if you're just starting out and don't have an existing code base you're attached too. It'd be very difficult to port an Android game to Unity. –  Neeko Dec 4 '12 at 18:40
I'm changing the accepted answer to this. I had accepted shivan's because the anwser is ultimately 'no' and he was the first to call it, but after installing libdgx I figured it is an 'almost yes' so this answer was the one which helped more. Thanks to both of you. –  petervaz Dec 5 '12 at 12:20
Awesome, glad it worked out for you. –  Neeko Dec 5 '12 at 14:41
add comment

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.

share|improve this answer
Thought as much, but wanted to be sure. Thanks for your anwser. –  petervaz Dec 4 '12 at 14:18
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.