G’day G’day! Tim Buchalka here again, the Aussie Android Dev Guy and in today’s video we are going to go ahead and configure and setup ‘libGDX’ which is a game framework using Android Studio for a Windows machine. Now libGDX, as I mentioned is a game framework. It’s a free and open source one. And it actually supports, so many different aspects of game development, it’s really really popular. Lot’s of games have been developed with it. And again, just to confirm this, we’re going to go through and configure it and install it and set it up using Android Studio for a Windows machine. So, let’s get into it.

The best way to get up to speed is to watch the video on this page.

If you click the youtube logo at the bottom right of the video you can watch this video on Youtube in the proper size.

click-the-youtube-logo

Downloading The Setup File

So first things first, let’s do a search for libGDX in Google. Now that will take you to ‘libgdx.badlogicgames.com’. You’ll just go in there. Click on the link in the search result to open it, and you’ll go to ‘Download’ section. And click on ‘Download Setup App’. And, you’re going to ‘Save’ that. It’s only a small file, so it’s going to download quickly. You are going to go into the folder where you saved the file in and you are now going to double-click it (gdx-setup). You can see that by double-clicking it, it has now opened this libGDX Project generator.

libgdx-download-page-for-windows

Now what this does, it will actually create a structure that we can then import into Android Studio. So this is a once only setup. Once you set it up. From that point on you don’t use this project generator anymore, you go into Android Studio. So, what it needs is a few things. It needs the ‘Destination’, it needs to know the ‘Android SDK’, and obviously the ‘Name’ and ‘Package’ and ‘Game class’.

libGDX Project Generator (SDK Destination)

So, let’s start with the ‘Android SDK’. So what you need to do now is open Android Studio. You’re going to click on ‘Start’ and open Android Studio through it. You’re just going to go in and have a look at the Android SDK location again and you’re going to paste that in. You could also use that browse button if you wanted too, but this is probably quicker to just paste in the location. So to find that, click on ‘Configure’, ‘Project Defaults, ‘Project Structure’ and you can see that’s the location there, your SDK, so you’ll take a copy of that. You’re going to click (‘Cancel’) to get out of that window. You’ll go back to libGDX Project generator and you’re going to paste that into ‘Android SDK’.

libGDX Project Generator (Project Destination)

Next, we need to know where the ‘Destination’, where you want to create this project. Now this should be the directory where you’re creating your projects, because what you’re doing is, once you open it in Android Studio, it doesn’t copy it to another location. It opens it in that location. So this should be the location, so obviously the default Downloads folder is not a good option probably for your projects. So, you’re going to go back to Android Studio You can see by default that the default folder was the home folder ‘AndroidStudioProjects’. So we can just confirm that; open up ‘Explorer’. Go into timbuchalka and there’s ‘AndroidStudioProjects’.

So if you open ‘AndroidStudioProjects’, you’ll just create a subfolder and call it ‘test’. So what you would do for that one (go back to libGDX and choose) ‘Destination’ (click ‘Browse’). Then ‘go back’ (click drop-down menu at top of window) ‘timbuchalka’, ‘AndroidStudioProjects’, then click on ‘Open’. You’re also going to add a subfolder, you’re going to call it ‘test’.

libGDX Project Generator (Game Name)

And next you need to come up with a game name. Let’s start with something simple, you’re just going to call it ‘My First Game’.

libGDX Project Generator (Package Name)

‘Packages’! We’re not going to talk too much about that in this video. You need to come up with a unique package. For this example call it ‘com.timbuchalka.myfirstgame’.

libgdx-project-setup-for-windows

libGDX Project Generator (Game Class)

Likewise for game class. This is the class that’s executed. The main game class. So you’re just going to leave in ‘MyGdxGame’.

libGDX Project Generator (libGDX Version)

The libGDX version will change depending on when you downloaded the jar file.

libGDX Project Generator (Sub Projects)

Now the Sub Projects, you’re only dealing with Android here, so you’re going to click ‘OFF’ Desktop, IOS, and Html so that you only have Android.

libGDX Project Generator (Extensions)

Now these are optional ‘Extensions’ that provide a lot of functionality, so you might want to consider using some of those. Some of them are really good. You can hover over them to see what they actually do, if you’re not sure.

So ‘Bullet’ is a physics library. ‘Freetype’ is a light weight font library. ‘Tools’ gives you things like a Texture Packer and creation of bit-mapped fonts. ‘Controllers’ is for game pads and joysticks. ‘Box2d’ is a physics engine and ‘Box2dlights’ goes with that. It gives you lights and shadows that work with ‘Box2d’. ‘Ashley’ is an entity framework, an artificial intelligence as well, so that’s all. These are all extensions that are part of ‘libGDX’.

libGDX Project Generator (Extensions)

And optionally you can go into ‘Third party Extensions’ and you can see there’s a ‘level’ editor you can grab that as well if you wanted too. Now select which ones you want, you don’t necessarily have to use them but it’s probably a good idea at this project generation time, if you know your going to use those, to actually add those. Now for the purposes of this test, I won’t do any of that now.

libGDX Project Generator (Generate)

So once you’ve selected everything there, you’re going to click on ‘Generate’. It comes up with a warning, or it may come up with warning because you’ve only just updated Android build tools, it’s saying this is a more recent version. D’o you want to use this version?’ you’re going to say ‘Yes’ but if there was a problem, you could always go back and download the older version of the build tools that you need and try again, but in this case you’re going to click on ‘Yes’. Because mostly it’s going to be okay. Likewise for the API. I do know that it works under Android Lollipop. But if you wanted to go back to an older API you could do that as well, but I’m going to leave it on API 21 as well and click on ‘Yes’. And of course it knew that by looking in the Android SDK folder as to what you’ve downloaded and used.

libgdx-project-generated-in-windows

Down at the bottom of the screen now, what it’s doing is generating this project. So it has to actually download some more files that are necessary for this project to actually work. Let that finish.

Okay, you can see there that the build has been successful. It took about 1 and one-half minutes on my machine. It’ll be dependent on the speed of your computer and the speed of your internet. So you’re now finished with the project generator, so we’ll close that down. And we’ll shoot back to Android Studio.

Importing libGDX Project To Android Studio

Next, you’ll just go back to the main menu (Quick Start). And you can select ‘Import Non-Android Studio project’. Click on that. You need to navigate to the folder that contains the project you just had created using the libGDX Project generator. If you recall that was in ‘Users’, ‘timbuchalka’ (in my case), ‘AndroidStudioProjects’ and there was a folder in there called ‘test’. So you’re going to select that ‘test’ folder. Click ‘OK’. And Android Studio will come up and open that for us.

Now if you get this message about the Gradle plugin, click on ‘OK’ and it will be upgraded for you automatically. Now the first time that Android Studio goes ahead and imports this project into Android Studio it will take a little bit of time, so keep that in mind and also, just to be clear, not only is it importing it into Android Studio it’s importing it into the same folder, so it’s not creating a new folder structure somewhere else. It’s just importing that code into Android Studio.

So once you’re done and it has finished importing, you’ll be able to do all your editing for the game within Android Studio. You won’t need to go back to that project generator. That was like a once-off and something you won’t need to worry about that again. You do get this message, ‘Language level changes will take effect when you reload’. ‘Yes’ you want to do that (click on ‘Yes’) and reload that. It’s the standard message that comes up when you import a ‘libGDX’ project. You’re going to ‘Close’ that, and I’ll just click ‘Allow access’.

libGDX Project Walkthrough In Android Studio

Now on the bottom, you can see the project is still chugging away now so it’s actually updating various repositories and grabbing the information. So again as I said it does take a while the first time, but once the project is in Android Studio. It’s a lot faster. You’re just going to click on ‘I don’t agree’ to this little dialog that comes up. We don’t need to send user statistics to Android or to Google. That’s got nothing to do with this project by the way. It just so coincides with the fact that I previously created a video for installing Android Studio.

Okay, the project is now completely loaded up on Android Studio. Now it did take a while. It does take some time the first time depending on the speed of your internet connection and just the processing power of your computer to install or try to import that project. But it’s now finished. You can see there’s no more processing down in the bottom right-hand corner. So, you’re good to go at this point, and just have a look at the structure.

libgdx-imported-to-android-studio-in-windows

You can see the manifest file is in there now. Java has been created automatically. Launcher code has been put in there. This has been code that was created essentially by the libGDX Project creator tool, the project generator. You’ve got all the standard things that you would normally have in a project as well. And, if you look in core, under ‘MyGdxGame’ remember that was the class that you chose, this is the code that’s going to be executed the first time when this project is created. and in this case, it’s just going to literally put an image on the screen. So that’s it in a nutshell.

And, we’re done. Dusted, complete, and fully setup. So ‘libGDX’ is now ready to go on your machine.

Please subscribe to my YouTube channel, to be able to keep up to date with the latest videos on app development for Android and games development as and when I release them.

Now speaking of content, please also leave some comments below the post. Let me know what you thought of the video, but also now perhaps more importantly what you’d like me to cover in future videos. Because I want to be the #1 premium resource for you for Android development tips, tricks, tutorials, and so forth.

But in order to do that, I need some feedback from you to know what you want me to cover in future videos, so please do that.

Tim’s Android Development Course

My course contains over Twenty-five (25)  hours of video training. With more being added regularly.
Teaching you, whether you’re a beginner at coding, or more experienced how to be a great Android app developer.  A fraction under 11,000  students have already taken my course and more are joining everyday.   I’d love to see you in there so come and check out what all the fuss is about!

Click here to access my Android Development course

All the best!

Cheers
Tim