Before we start, please understand that I am only one person and I am going through this tutorial for my own benefit. Because of that, I won't be able to cover all instances exactly. Particularly, I use a crummy old Linux laptop for coding and don't have access to either a Windows or Mac machine to test how things work on other operating systems. Where possible I will try to provide help, but since I won't be able to test it, I can't make any guarantees.
The first step is to ensure that you have Android Studio and the Java Development Kit (if you have trouble, make sure you installed the 'JDK' specifically).
Next, download the libGDX project setup tool and put it in a convenient directory. (Note there is an official setup guide, although it, too, is a bit out of date.) Now that you have all the necessary files, let's get started on importing a project.
1. From the command line, go to the directory where you saved the libGDX setup file (gdx-setup.jar) and type:
java -jar gdx-setup.jar
You should see this screen now:
2. Now it is time to set up the project.
- First, choose the name that you want to use. I will call my project Dot's Dots, but feel free to call your project whatever you like.
- For the Package name, I follow the Google Play naming convention, so will use com.petenotpete.dotsdots.
- Game class isn't overly important, but I will also change it to DotsDots because I like to be thorough.
- Destination is fairly important for ease of use. I want to create the project in the same folder as the rest of my Android Studio projects just for convenience sake. If you do this, you should specify the actual folder of the project, and not the generic projects folders. For example, in my case you would want to specify: /home/netbook/AndroidStudioProjects/dotsdotsIf you don't know where that is, or don't care, just save the project somewhere convenient for you.
- Android SDK location is obviously important, but it should be automatically filled in. If for some reason it isn't, you can find the location of the SDK by opening an Android Studio project and selecting 'File' -> 'Other Settings' -> 'Default Project Structure...'
- For the subprojects, I just leave the default. We will discuss a bit about web based and desktop applications, so they are good to have, and who knows, you might just want to publish your app to the App Store some day.
- Under extensions, I just leave the default 'Box2d' checked.
In both cases I hit 'No'. I am not sure how things will work otherwise, but I read of some fairly recent (as of early 2018) issues on Stack Overflow where the libGDX project wasn't compiling because it didn't work with the newest Android and Gradle versions so figure it is better to stick with the recommended versions.
Once that is done, go get yourself a cup of coffee and watch everything get set up.
4. Once the libGDX project generator says it is finished, open up Android Studio and open the project. Sometimes it doesn't show up in the menu immediately, but if you browse the directory structure you should be able to find and open the project.
5. When you open the project in Android Studio, it is likely you will get a popup similar to the following:
6. So now you should have the project open in Android Studio, and the next step is going to be getting the project to compile on desktop, HTML and Android.