LibGDX Project Generator 2019 Tutorial – Eclipse – Android Studio

Sharing is caring!

Over the past couple of years libgdx, eclipse and android have went through many changes.  These changes have made a lot of the tutorials online out of date so a new tutorial detailing the steps required to generate a new project was needed. So before we begin I’d like to note what versions I will be using in this tutorial to make it easier for you to follow along.

Software Downloads

The first thing we need is the LibGDX Project Generator

This can be downloaded from the libGDX website.

Next we need to get Eclipse Version 2018-12 from https://www.eclipse.org/ide/

and finally we get Android Studio 3.2.1 from https://developer.android.com/studio/

Project Generator

Now that you have the same versions taht are used in this tutorial you can follow along.
The first thing we will do is run the project generator. This can be done by double clicking the .jar file or right clicking and opening with java.

This should bring up a screen with all the inputs for setting up your project.

Project Generator Options

  • Project Name
    • The name of your project. This is usually written out all in lowercase with minus separators. E.g. skull-crushers
  • Package
    • This is the package for your game. Typically this is your domain in reverse with your game name. E.g. blog.gamedevelopment.skullcrushers
  • Game Class
    • This is the name of the main class for your game in Camel case. E.g. SkullCrushers
  • Destination
    • The location your project will be placed on your storage media. E.g. c:\projects\skullcrushers
  • Android SDK
    • This is the location of your installed Android SDK. This will be installed with the Android Studio IDE and will be in the C:\Users\{username}\AppData\Local\Android\Sdk
  • Sub Projects
    • This is where you select which platforms you want projects for. The options are:
      • Desktop: For projects that run on a typical desktop environment such as windows or *nix.
      • Android: For Android devices such as phones and tablets.
      • IOS: For Apple IPhones, IPads using MobiDevelop’s RoboVM fork
      • IOS-moe: Again for IPhones and Ipads using Intel’s Multi-OS Engine backend.
      • HTML: For browser applications.
  • Extensions
    • These are extensions you can add to your application. The current extensions are:
      • Bullet: A 3D Collision Detection and Rigid Body Dynamics Library for use with 3D games.
      • Freetype: An Extension to allow use of Freetype fonts.
      • Tools: A collection of tools such as:
        • Texture packer: packs images into larger files to increase performance.
        • Hiero: for creating Bitmap fonts.
        • 2D and 3D Particle Editor: To create 2D or 3D particle Effects.
      • Controllers: An Extension to add support for wired peripheral controllers such as the xbox controller.
      • Box2D: An Extension which allows you to add 2D physics to your game.
      • Box2DLights: An extension to use with Box2D to create lighting effects using ray-casting.
      • Ashley: A Component Entity Engine. More can be found out about this on www.gamedev.net
      • AI: This extension adds support for AI based Movement, Path finding and decision making.
  • Third Party Extensions
    • These are extensions added by third parties that can be used in LibGDX.
  • Advanced Options:
    • Maven Mirror URL: used to replace the default Maven Repository
    • IDEA and Eclipse: used to select the project types that are created. IDEA for Intellij IDE and Eclipse for Eclipse IDE.
    • Offline Mode: Used to disable the dependency download in your projects.

Some notes about libgdx and eclipse. Android is no longer supported by libGDX on the eclipse IDE due to the discontinuation of the standalone android SDK as well as other things. This means if you are making an android project you are better off using android studio.

Now the project generator is running and you have been told what all the settings are for enter your application details and select the target platforms and extensions you plan to use. Once done, click the generate button and you will be presented with some progress text like below

Once the Build Successful message is shown you can start to import the project into your preferred IDE.

Eclipse

In order to import the gradle project into your eclipse IDE go to File > import

Then select Gradle > Existing Gradle Project

Browse for the top level folder (This will be the same as the text you entered in the Name section of the project generator) and click finish to import the projects.

Now the project should be in your eclipse workspace and available for code editing. Projects like the HTML and android may still have issues as they may require additional steps e.g. installing and setting up GWT.

Android Studio

Android studio is by far the easiest IDE to add a libGDX project to as you simple need to open an existing Android Studio Project.

Navigate to the top level folder of your application (This will be the same as the text you entered in the Name section of the project generator)

Click OK and the project will be imported. One isse that may appear when importing is a popup message asking to upgrade Gradle. In my opinion this is not required and may in fact cause issues with your project setup. 

Once done you should end up with a screen like the image above and you can start to edit the code within the project.

Android Studio Running Desktop Configuration

If you try to run the desktop configuration in android studio you will most likely be prompted with an error saying that the badlogic.jpg file cannot be found. This is due to Android studio not setting the working directory for the desktop version to the Android asset folder. If you’re like me and prefer to test on the desktop first then you will need to follow these steps to set the working directory to the android assets folder before testing.

Step 1

Try to run the desktop version if you haven’t already tried. This creates a configuration for the desktop mode that can then be edited to set the working directory.

Step 2

Select Run from the top menu and scroll to edit configurations…

Step 3

Select the Desktop Launcher configuration and hit the […] button next to the working directory input box and navigate to the android > assets folder

Last Step

Select OK and then you should be able to run the Desktop launcher.

Sharing is caring!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.