but what... is it good for? ?

Setup (2/2): Gradle and LibGDX Project

What we're about to do:

  • Eclipse Gradle Plugin
  • LibGDX Setup Tool (Download)
  • Projekte Eclipse-Import
  • Run HelloWorld

Within the scope of this post, we will finish setting up our libGDX development environment. After we already prepared our machine to develop Java by installing the Java Development Kit (JDK) and Android by installing the Android SDK (we did it here), we are going to take care of the proper implementation for the build automation tool Gradle, its integration with Eclipse and the creation and integration of the libGDX project files.

But what do we need Gradle for? Gradle allowes us the dependency and version management of the software tools and frameworks used in our projects in a very simple manner. For example, it helps us out with the updating process of the libraries like libGDX or box2d physics. In earlier days, before gradle and before other dependency management tools, it wasn't always easy to find the necessary resources, change them and link them together in the right way in your project. Gradle completely removes this burden from our shoulders. A fully fledged Gradle tutorial would be out of the scope from this tutorial, though. If you want do deepen your knowledge about gradle, feel free to check this site out.


First, we need to install the Gradle-Plugin for Eclipse:

  1. In Eclipse: go to help / install new software

  2. We need an new software location for the Gradle plugin: Press the 'add' button and save the new location with the name of 'gradle plugin' and the location "http://dist.springsource.com/snapshot/TOOLS/gradle/nightly"
  3. Choose the newly created location in the combo box work with. The grid should refresh. Check the option Gradle IDE  below Extensions / Gradle Integration and klick Next.

  4. After finishing the install process, eclipse wants to restart. Perfect. The plugin should be installed correctly

  5. Test your installation by right-clicking the package-explorer in eclipse and choose the import option in the context menu. In the following dialog, a folder "Gradle" and a subfolder "Gradle Project" should be present. If you see it: Congratulation. If you don't: Hm. You have done something wrong, obviously.

Now let's talk about the libGDX project setup:

The creators of libGDX are making things really easy for us nowadays. Download the executable jar file by clicking the button "download setup app" on the libGDX project site's download section. It will take care of the project-creation, the creation of all cradle build files and the internal linking of the project folders (assets, resources).

What is left for us to do:

  1. After executing the jar, you reach the project setup
  2. We will do just a little test project. Thus deactivate all the extensions there are. The extensions Box2d, Box2d Lights, Controllers, Freetype and Ashley will be covered in seperate articles in the future. Fill the textfields with hello world data and choose a destination on your hard drive, where the setup tool should create your projects.
  3. After pressing "Generate" the tool will download some dependencies and afterward it will create the projects. This step can take a little wihle, depending on your hardware and internet connection. So please be patient.
  4. Everything is ready and findished and you got a success message? Congratulations. Everything is going according to plan.

Back to Eclipse-land:

So far, so good. If everything went right, there now are some helloWorld libGDX projects on our hard drive. What is left, is to import them into the Eclipse workspace. Do it this way:

  1. As mentioned earlier, open the context menu on your project explorer by right-clicking and choose the Import option.
  2. Choose the gradle project
  3. Select the root folder where your created gradle projects are under. It is the folder, you chose in the setup tool as destination folder.
  4. Click the button "build model". Gradle now searches all dependencies in the build.gradle files for downloading and linking the right software components into the projects.
  5. After everything finished successfully, you can see the projects to import. Check them and click "Finish"
  6. You should be able to find a core project (where we are going to do the main programming for the game) and a start project for every platform you chose in your package explorer.
  7. Don't be frightened: The Android project might be shown with errors at first. It is only a minor configuration problem. The suggested Android API-Level for libGDX might not be available in your Android SDK Manager. This is no problem at all. We will give the project one of the existing API levels. Right-click on the android project and select "Properties". In the Android Section, select an available build target and afterwards click ok. Problem solved.

  8. Gratulations. If the projects are layed out like in the screenshot and there are no problems left in the error/problems section, you get an A with a star. If your outcome differs from the screenshot, you should think about changing your profession. Gardener, for example, they say is a very gratifying job and might be just right for you. 

Executing your first libGDX application:

The time has come. The moment, you most likely been waiting for. For the first time, you will execute an app on your machine. The project manager already created a little hello world application, doing nothing more than showing the BadLogicGames logo.

How to execute on the desktop:

  1. Expand your desktop start project and work your way to the launcher class (like in the screenshot)
  2. Right-click on the launcher --> Run as --> Java Application
  3. Yay. Congratulation! This is it. The first libGDX app running and rendering the very first image.

The next post will engage in proper game project architecture. Which classes are there, which one should you use, what is the libGDX application lifecycle and how to begin to code a game.

How to execute on an android device:

Oh, one more thing. You might want to try your newly crafted application on your android device. Therefore it is necessary to get developer rights on your android device, USB debugging is activated and your PC has the right set of drivers installed. First and second is easy as pie. Since Android 4.2, the developer options are in fact hidden, but can be un-hidden very easily:

  1. Open the settings of your android device
  2. Scroll the menu to the point "About phone"
  3. Tap repeatedly on the build number (it will say so, when you achieved your job)
  4. Afterwards you will find the developer options in the system menu
  5. Activate USB debugging there

If you own a Google Nexus device, you can install the drivers for windows in your Android SDK-Manager. Just go to Tools/USB-Driver and check them. Most of the other vendors are offering their drivers free of charge in the download sections on their homepages.

During the install process of the Android Development Tools (ADT) for Eclipse, you installed the DDMS perspective too. Simply select in Eclipse Window --> Open Perspective --> Other --> DDMS. There you can see, which Android devices are recognized as developer devices from the IDE. You can run your application on these devices as well. If you made shure your device is there, switch back to the Java (default) perspective.

  1. Right-click directly (!!) the Android project and open its context menu
  2. Run As --> Android Application
  3. A dialog should open, showing you the available android devices. Choose the one, you want your app to run on.

This is all for now. I hope, it was helpful for the one or two.
Have a nice day, Michaell

Last modified onTuesday, 26 March 2019 12:00
Michael Wagner

...is a software developer (focus on App/Webdev, UX/UI, IoT) located in Lower Austria.  When he is not working on new app ideas, web applications or game designs, he teaches webdevelopment at the university of applied sciences St. Pölten. In his spare time he usually plays and streams videogames, tinkers with various webdev tools, does some sports, is making music with cubase and his electric guitar or hitting the fields with his cam. Since 2010, he is certified business administrator for applied computer science, in October 2020 he achieved his Master of Sciences (M.Sc.) degree in "Web and Mobile Media Design" at the Danube University Krems.

Email This email address is being protected from spambots. You need JavaScript enabled to view it.
FaLang translation system by Faboba