How to port a java game to android

Hello,
I started to learn java because I wanted to make games for android and people sujested that at first I need to learn how to program to the pc and than move to android. I made the game with basic java with no libraries.I have heard that I can use the libgdx library to easly port to android but is it too late for me? Any ways what is the easiest way to port to android?
Thanks alot!!

Do you already have a game made?

Yes, its almost finished

To “port” a game to android using LibGDX you probably will be better off developing your desktop version in LibGDX as well. What are you currently using as a framework? Just plain Java2D? Porting will probably involve quite a bit of work.

Im using just java2D…
So where do I start? It wont work if I start a new libgdx project and copy paste it and just change the input?

How big is your game? Is it written some kind of wrapper? If you really are programming for less than a month, I doubt you made a big game… All the code should work except the code related to Java2D stuff. (Rendering)

I didnt use anything special,its just a basic 2d platformer.
So how do I do it?

If I was doing that… I would setup libgdx and spend a few days understanding how it works. Then id create a new project and copy and paste parts of the old version into the new project, modifying things as I went to make them work with libgdx. If you do it carefully you can build it back up in an order where its always runnable so you can test it as you go, rather than trying to fix everything in one step and hoping it will work.

I agree with Liquid. You should look into LibGDX and figure out how to make a basic game using it. Once you understand that, you should have no problem adapting (porting) your code to how LibGDX works.

Don’t try to port it. Just rewrite it using LibGDX. Doing the “same” the second time is just good practice…

Okay thanks I will rewrite it with LibGDX.
Anyone can point me to a good LibGDX tutorial?

The main LibGDX wiki on Github would probably be the best place, otherwise use google or ask specific questions on the forums: https://github.com/libgdx/libgdx/wiki

I was planning to port my Java 2D game to Android so I originally wrote it with an abstraction layer so I could swap in Android stuff in place of AWT at a later stage. That was before I started coming here and found out most people think LibGDX is the best way to go.

Any thoughts about whether I should bother implementing the interfaces in Android (if only out of curiosity) or should just forget it and just go directly to LibGDX? Is it worth acquiring that level of knowledge about Android IO if one’s just going to use LibGDX in future anyway?

Old C++ habits make me look at adding a dependency on a 3rd party library as quite a big decision. Various reasons, not just commercial ones. E.g. some C++ libraries add huge bloat to your distribution size unless you work really hard to trim out bits you’re not using. As I understand it LibGDX is mainly just wrappers though right?

If I was in your position, I personally would just go straight to LibGDX. LibGDX allows you to code your game in one way (aka Using a single code base) and then with little to no extra code, you can export your project to many different platforms; including HTML, Desktop, IOS, and Android.

Best way for me to explain that is just to direct you here: http://libgdx.badlogicgames.com/features.html

Thanks yes this has to be right. I’ll finish prototyping with Java2D then if the game’s good I’ll rewrite in LibGDX as part of polishing up the presentation. If it sucks I’ll start the new one straight in with LibGDX :smiley: