4
\$\begingroup\$

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?

\$\endgroup\$
2
  • 4
    \$\begingroup\$ Port the whole thing to libGDX, that should do the trick :) \$\endgroup\$
    – Engineer
    Commented Dec 4, 2012 at 13:27
  • \$\begingroup\$ Or Haxe/NME, or cocos2d-x, or a few other cross-platform libraries... :) \$\endgroup\$
    – Liosan
    Commented Dec 4, 2012 at 14:50

2 Answers 2

5
\$\begingroup\$

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.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ +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). \$\endgroup\$ Commented Dec 4, 2012 at 16:17
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Dec 4, 2012 at 18:40
  • \$\begingroup\$ 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. \$\endgroup\$
    – petervaz
    Commented Dec 5, 2012 at 12:20
  • \$\begingroup\$ Awesome, glad it worked out for you. \$\endgroup\$ Commented Dec 5, 2012 at 14:41
5
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ Thought as much, but wanted to be sure. Thanks for your anwser. \$\endgroup\$
    – petervaz
    Commented Dec 4, 2012 at 14:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .