This post details my experience with integrating the libGDX game engine into a new Android Studio project on my Linux machine (running Ubuntu); it is intended as a simple walk-through of the process I followed.

*Disclaimer: I am not an expert. In fact, I am learning most of this as I go along.


  1. Background
    1. Goal
    2. Why libGDX?
  2. Prerequisites
  3. Getting Started
    1. The Official libGDX Documentation
    2. Downloading the libGDX Setup App
    3. Installing Java
  4. Creating a libGDX Project
    1. Generating the libGDX Project
    2. Importing the Project into Android Studio
    3. Running the libGDX Android Project
  5. Conculsion



The goal for this walk-through is to create a new Android project that integrates the libGDX. By the end, we’ll have a bare bones “Hello World!” style program that initializes an OpenGL context and renders a simple scene to show it’s working.

The primary focus of this guide will be on supporting the Android platform, however we will also be creating projects to target HTML5 and PC [Desktop] (Because why not?).

*Sorry, iOS will not be covered here. You should still be able to follow along for this guide, but make sure to check out the libGDX Docs for more information on additional platforms.

Why libGDX?

libGDX is an OpenGL engine library for Java, with a heavy focus on game development. The library is completely open source and supports multiple target platforms out of the box.

Now, deciding middleware is never an easy task, especially for something as important as your Engine. There is no definitive guide or a right or wrong answer here; it really all comes down to your project’s specific requirements (and personal preference). I’d encourage everyone to do some research on their own, and maybe even experiment with a few different engines before making your final choice.

All I can offer are some of my own reasons for going with libGDX:

  • Android Support
    • My primary target is Android, so this was a must.
    • The additional target platforms (PC, HTML5, and iOS [at time of writing]) are just icing.
  • Java
    • I made the choice to work with Java instead of writing native code in C++.
      • I write C++ all day at work
      • My project really won’t require the raw performance of a native engine.
    • And if we’re honest, there really aren’t many alternatives for Java based OpenGL engines.
  • Lightweight
    • This was somewhat important for me, since I personally like a decent amount of control for how I layout my project and it’s pipelines.
      • A mix of NIH (Not-Invented-Here) and a desire to learn the underlying techniques and principals.
    • There are much better options if you want to buy into a complete engine and asset pipeline right out of the box (Unity3D or any of the other paid engines)
      • [Okay, maybe not if you want to use Java :P]
  • Support for basic Input, Audio, and Networking
    • Besides rendering, this is all I (and probably a lot of indie types) really need to roll out a solid little project.


This guide begins assuming that you already have a working copy of Android Studio installed on your system.

If you haven’t already setup Android Studio, you will need to install the following:

Getting Started

We are going to use the libGDX Setup App to make a new libGDX project. The application will automatically generate all the necessary build configurations to create new projects for all our target platforms.

The Official libGDX Documentation

Please consult the official libGDX documentation before getting started.

Downloading the libGDX Setup App

Download the latest libGDX Setup App from the official libGDX Downloads page, and then navigate to the folder where it was downloaded.

$ ls

*Note: You can alternatively download the libGDX Release & Nightly builds and setup your projects manually if you are integrating libGDX with an existing project or require custom project settings.

Installing Java

To run the Setup App, you must have the Java Runtime Envirement (JRE) installed. If unsure, you can check what version of Java (if any) is currently installed with:

$ java -version
java version "1.7.0_79"

If necessary, install Java now.

$ sudo apt-get update
$ sudo apt-get install default-jre

Creating a libGDX Project

Generating the libGDX Project

To start up the Setup App, simply execute the JAR file gdx-setup.jar downloaded earlier.

$ java -jar gdx-setup.jar

The libGDX Project Setup will display the following dialog, where we can change set all the parameters for the new project.

Enter the project Name, Package, and Game Class, and select the Destination directory where the project should be created and the folder where the Android SDK is located. Then check all of the platforms you would like to target and any optional extensions you would like to included.

Once you are done setting up the project, click the Generate button to create the project. When the process completes there will be folders for each of the target platforms you selected.

These projects can now imported into the IDE of your choice, such as Android Studio.

Importing the Project into Android Studio

Launch Android Studio and select “Import Project (Eclipse ADT, Gradle, etc.)” from the initial dialog. (You may need to close a previously opened project first, File->Close Project)

In the open file dialog that appears, navigate to your newly created libGDX project and select the build.gradle file from the root project directory.

It may take a few moments for Android Studio to initialize your libGDX project. Once the import process has completed, we can finally start using the new project.

Running the libGDX Android Project

To Run the new Android libGDX project, simply click the green “Play” button on the toolbar at the top. This will automatically build the Android Module, before launching the Android program.

A dialog should prompt you to select your connected device or simply launch an Emulator. If you have a device connected, select it, otherwise just pick the emulate and hit OK.

If all went well, you should see the default libGDX project rendering on your device.


Thanks to the official libGDX Setup App, setting up a new project and importing it into Android Studio is pretty painless.

If you’d like, you should be all set to jump straight into developing your Android project. However, if you’re like me, we still have to finalize our other target platforms and setup some additional build processes.

We’ll save that for next time though…