Before you can start writing any application or game with LibGDX, you need to download and install the library and some additional software.
To target Windows, Linux, Mac OS X, Android, and HTML5, you will need to install the following software:
To additionally target iOS, you will also need:
Due to the fact that LibGDX is a framework based on Java, it is necessary to download Java Development Kit (JDK). To install it, follow these steps:
You will have to accept the license agreement and choose the version that is appropriate for your platform. For example, if you are using a 64-bit version of Windows, choose the download labeled as Windows x64. Here, we are using the 32-bit version that is labeled window-i586:
jdk-8u5-windows-i586.exe
) and follow the instructions on the screen:The next step is to download and install Eclipse, a freely available and open source Integrated Development Environment (IDE) in order to develop applications in Java. Go to http://www.eclipse.org/downloads/ and choose Eclipse IDE for Java Developers, as shown in the following screenshot, to download for the platform you are using:
Once the download is finished, extract the archive to C:eclipse
.
Go to http://libgdx.badlogicgames.com/releases/ and choose the libgdx-1.2.0.zip
file to download LibGDX.
The following screenshot shows a list of all the available files:
In the meantime, create a new folder inside the root folder of your C drive with the name libgdx
. Once the download is finished, move the archive to C:libgdx
.
The Android mobile OS is one of LibGDX's supported target platforms. Before you can create Android applications, you have to download and install the Android SDK.
installer_r22.0.4-windows.exe
) and follow the instructions on the screen.JAVA_HOME
to the installation path of the JDK. To find the correct path, go to C:Program FilesJava
. You will see a folder starting with jdk
. Take the full name of this folder (here, it is jdk1.8.0_05
) and append it to its path, as shown in the following screenshot:C:Program FilesJavajdk1.8.0_05
. Now you have to set the environment variable. Click on the Windows Start button and right-click on Computer. Then click on Properties to open the control panel system window, as shown in the following screenshot:JAVA_HOME
in the Variable name field and the JDK's path you found earlier in the Variable value field, as shown in the following screenshot:Great! Now your system is prepared for the Android SDK installer. Make sure to exit the Android SDK installer if it is still running to let the change take effect. You will be presented with the next screen after the installer has restarted.
The Android SDK Manager enables you to download system images for the specific API levels you want to develop applications for. For up-to-date and detailed information about Android API levels, check out the link http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels.
Great! You are almost done setting everything up. The remaining steps involve running Eclipse for the first time and installing important plugins, which are required to develop applications for Android, iOS, and HTML5/GWT with Eclipse.
Open Windows Explorer, and go to the location where you extracted Eclipse (here, C:eclipse
), and simply run the program by double-clicking on the executable called eclipse
.
Eclipse will ask you to select a so-called workspace. This is the folder where all your projects will be saved. We want to use the C:libgdx
folder we created a bit earlier:
Select the Use this as the default and do not ask again checkbox if you don't want to see this dialog box every time you start Eclipse. To proceed, confirm the dialog box by clicking on the OK button.
The first time Eclipse is started with a new workspace, it will greet you with a welcome screen. Simply click on the small cross (x) of the Welcome tab to close it:
You should now see the standard view of Eclipse, which is also called the Java Perspective. On the left-hand side, you can see the Package Explorer section, as shown in the following screenshot. This is where you will see and manage your different projects. This is all you need to know about Eclipse for the moment.
If you have never worked with Eclipse before, it might seem quite overwhelming with all these windows, toolbars, huge context menus, and so on. However, be rest assured that all the steps will be discussed in detail as required to make it easy for you to follow.
To install new plugins, go to the menu bar, and click on Help, and then click on Install New Software. This will open the Install window, where you can type the special repository URLs to browse for new plugins. Google provides a list of such URLs at https://developers.google.com/eclipse/docs/getting_started. You have to choose the correct URL that corresponds with your Eclipse installation.
At the time of writing this book, Eclipse 4.3.2 (Kepler) was the most current version available. According to Google's website, the suggested URL for our version is http://dl.google.com/eclipse/plugin/4.3.
Type the URL in the text field that is labeled Work with and press return to let Eclipse request a list of available downloads. Select everything in the list that is shown in Developer Tools to add support for Android applications. Then, select everything in Google Plugin for Eclipse (required) to install the required Eclipse plugin. Lastly, select Google Web Toolkit SDK 2.5.1 in SDKs to add support for HTML5/GWT applications and click on Next to continue:
Now, click on Next to start the installation:
You will now be prompted to accept the terms of the license agreements by selecting the I accept the terms of the license agreements option. You have to do this before you can click on Finish to continue, as shown in the following screenshot:
The download process should only take a couple of minutes, depending on the speed of your network connection. When downloading is finished, Eclipse will show a security warning that you are about to install unsigned content and wants to know whether it should continue or abort. There is always a potential risk of installing malicious software. However, in this case, the download is provided by Google, a well-known company, which is trustworthy enough. Click on the OK button to accept the warning and continue the installation, as shown in the following screenshot:
After the installation is finished, a final restart of Eclipse is required. Click on the Yes button to confirm the restart:
Now, let's install the Gradle plugin for Eclipse so that we can import the project into Eclipse via Gradle. For this, let's perform the previous steps again. Go to the Install New Software option in the Help menu.
Enter the URL http://dist.springsource.com/release/TOOLS/gradle
in the Work with field:
Select Gradle IDE under Extensions / Gradle Integration and click on Next. Continue as you did while installing Eclipse plugins to finish the process.
Additionally, in order to enable the iOS development, you need to install the RoboVM plugin in Eclipse. RoboVM for Eclipse integrates the RoboVM AOT (ahead-of-time) compiler with the Eclipse Java IDE. With this plugin, you will be able to develop native iOS apps in Java and launch them on the iOS simulator and iOS devices from within Eclipse.
To download and install the latest RoboVM plugin, we will perform the same steps that we did to install Eclipse plugins earlier. Go to the Install New Software option in the Help menu.
Enter the URL http://download.robovm.org/eclipse/
and continue, as shown in the following screenshot:
The latest RoboVM release while writing the book was v0.0.13.
Congratulations! You have just finished the installation of everything that you will need to develop and build your own games with LibGDX.