Well, G’day G’day, it’s Tim Buchalka here again the Aussie Android Dev Guy and in today’s video, we’re going to go ahead and setup ‘libGDX’ for the Mac. Now in case you didn’t know, libGDX is a framework for creating games. Its a fantastic framework, free to use, and really really worthwhile. It’s written in Java, but it also supports other platforms. In this video I am  going to focus on configuring that for Android Studio on a Mac. Let’s get stuck into configuring and installing the libGDX library for Android Studio on a Mac.

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

Okay, we want to search for ‘libGDX’ or I could have just gone to ’libgdx.badlogicgames.com’ instead, click on the link you first see on the search results page in Google, and go to ‘Download’. Click on the ‘Download Setup App’ link. It’s only a small file, so it won’t take long. You’re going to click into there. And now you just need to double-click to open it, now if you’re going to get this message saying ‘it can’t be opened because its from an unidentified developer’ that’s because of the security preferences you’ve setup in system preferences.

libgdx-download-page

You can easily overcome that by going into ‘System Preferences…’ and ‘Security & Policy’ and you can see down here because it’s the last thing you’ve opened, you can either go through and click the ‘lock’ to make changes and then pick ‘Anywhere’ or you can just click on ‘Open Anyway’, which just lets this application open once. So, your just going to do that in this case to save you having to change any other preferences. After that ‘close’ down preferences, and you’re just going to click on ‘Open’ now. And, that’s going to invoke Java and then run this application so you can setup the project.
libGDX Setup Window (SDK and Destination Path)

So this is how you go about setting up a new libGDX project for the first time. Now there’s a couple of things you need to know. You need to know the destination where you want to store your files. This is to store the project that it creates, and also the Android SDK. So, the easiest way to find both of those, is to go into Android Studio. So, you’re going to hold down ‘Command’ and press ‘Space’, type Android and press enter to start it. And again, you’ll probably recall this from the previous video, you are going to click ’Configure’, click ‘Project Defaults’ and ‘Project Structure’. And, that’s going to show the location of your Android SDK, so you’re just going to ‘Copy’ that and (Click on) ‘Cancel’ once your done copying.

You’ve taken a copy and you’re just going to ‘Tab’ back over to the libGDX setup window. That’s going to be our Android location. You could have just browsed there as well, but it’s easier just to actually paste in the location. Now the destination is where you want to save the files. This is the project files. So you probably, when you setup Android Studio what you should have is a folder somewhere where you store all your projects. So going back into Android Studio, you haven’t got a project yet but you can go back and create a new one. And you can see in the ‘project location’, here is where it’s going to be putting them. So, it’s going to be putting them in that path there, so you’re going to select that component. Not the name of the app, but everything other than that. Again, ‘Cancel’ out of that. You’ll ‘Tab’ back to the libGDX setup window again, and you’ll paste in the destination.

libGDX Setup Window(Name and Package Name)

You’re also going to put in the name of the project. In this example just call it ‘Test’. So, the other things you need to know is the name. Obviously it’s going to be a test, but you would put in the the real name of your project in the Name field. For this example just put in ‘Test Game’. Package, again, is normally the name of your domain in reverse notation. So if the name of your domain is ‘timbuchalka.com’, what you would enter here is com dot timbuchalka, and by convention, its normally the name of the game, so dot (.) testgame ‘com.timbulchalka.testgame’. The idea of that is that needs to be a unique identifier across all of Google Play. So the way to do that is, because it’s your domain, it’s much easier to do it that way. And there’s other ways of creating packages that are outside the scope of this video. I’ll look to address that in an additional video. But now you just need to put something in there.

libgdx-project-setup

libGDX Setup Window(Game Class)

And ‘Game class:’ is going to be the main game class that contains the code to start the games. Let’s call it ‘StartGdxGame’. Okay, so that’s pretty well everything that you need up to that point. The libGDX version, that’s usually only the latest release anyway. Release 1.5.4 has only just come out as I’m recording this video.

libGDX Setup Window(Sub Projects)

Now ‘Sub Projects’, libGDX works on other platforms, so you can specify other platforms. ‘HTML’, ‘IOS’, or ‘Desktop’. I’m only going to select Android here, but you can do that if you wanted too.

libGDX Setup Window(Extensions)

But there are also some optional extensions that you can download, and some of these are really pretty cool. I mean if you wanted too, you could just literally just select everything. I’m going to go through and tell you what they are. Bullet is a physics library. Freetype is a way for you to have light weight fonts. Now the ‘Tools’ has got things like ‘texture packers’ and ‘bit-map font generators’ and those types of things. Controllers is for game pads and joysticks. Box2d is a 2d graphics lib… physics library I should say. And the ‘Box2dlights’ enables functionality for lights and shadows in 2d. Ashley is an entity framework and AI, which is a library that is built-in to or part of as an extension to libGDX.

libGDX Setup Window(3rd Party Extensions)

You can also Show Third Party Extensions if you want too. There’s one on there called ‘Overlap’ which again is a Level and UI editor, so this will change over time as well. So the great thing about this is there’s lots of different packages there that are available so you could select any the ones you wanted too, any or all of them, and they’ll be included in the project we’re creating.

libGDX Setup Window(Advanced)

‘Advanced’! You don’t really need to go into but I’ll just show you that there now. That’s if you wanted to create an Eclipse project, or an IDEA project or an Offline Mode. You don’t want to do any of that, you don’t need to because you’re using Android Studio. Now ‘Cancel’ out of that advanced window.

libGDX Setup Window(Generate)

The next option now is just to click on ‘Generate’. Now this may come up with a warning, but that’s because you’ve installed the very latest version. You’re going to click on ‘Yes’ and use it anyway. If there was a problem, you could always go back into SDK Manager which again you can reference that from Android Studio and download a previous version. But in general, the way that the tools are built, it’s Okay to use the latest version. Click on ‘Yes’ on the warning window.

You can see now on the bottom of the screen, it’s coming up with a message and it’s generating. But, it does take a while to finish, because it’s actually has to download the files. The initial download was really only a setup program. that enabled you to type in those parameters, and then to choose what options you wanted for the project. It now needs to download the physical bits and pieces that form part of this entire project, so that it can then open up in Android Studio.

libgdx-project-setup-build-generate

Okay, once it has done processing down in the bottom left hand corner, you’re done. It will take about a minute to actually finish off the compilation. At this point, you’re actually done and you can close the libGDX setup window.

Loading Up The Project In Android Studio

You can go back over into Android Studio again now. The quickest way to import the libGDX project is to just click ‘Import ‘Non-Android Studio project’. Now click on that. So the good thing about that is that’ll import the project into Android Studio but also keep it in the same folder. So, you now need to navigate to the folder where the libGDX setup has created the project. As you recall, that was in AndroidStudioProjects and we had a folder called ‘test’. You’re just going to click on ‘test’ there and click on ‘OK’. And, if you do get a Gradle Sync message just click on ‘OK’ and Android Studio will nicely update things for you. Again, it has to fiddle around and go through the project and figure out the dependencies and so forth. So that may take a couple of minutes depending on the speed of your computer and also the download speed, because it is downloading a few extra files.

Okay, the project is still chugging away. In the bottom right hand corner it’s processing away and just setting up the project. Once that finishes, we’ll just have a quick look at what it’s created. What I mean, to be more technically correct, it hasn’t created anything, it’s opening this project and it’s really creating a structure around it so it works within Android Studio. And, from this point on, once you’ve imported this project for the first time, you can open and close this project as you would any normal Android Studio project. It does take a few minutes to finish this and it will take that the first time.

Okay, once it’s all imported into Android Studio, you’ll find it’ll be much faster and more responsive at subsequent times when you’re opening the project. Okay, you can see there that we’re done, so if we ‘Close’ that Tip of the Day window, you can now go into the Android project. You can go into the Android project now, and have a look at the standard manifest file (AndroidManifest.xml).

You can see that it’s automatically put the various bits and pieces we chose. Obviously into the ‘testgame’. It’s also added the package ‘.android.AndroidLauncher’ as well because of course it is cross-platform, and there’s some Java code there. Just the basics to get you up and going. But that’s actually a project now in its own right and, under ‘core’ are the core components of GDX.

libgdx-imported-in-android-studio

It’s a start. You can see that by default, this project will actually run and show the ‘Badlogic’ jpeg on the screen. There are also some Gradle scripts and they are part of original created project. You can see they are listing various repositories and so forth and various natives and so forth. But, they are all particular to this platform. So that’s it, that’s setting up ‘libGDX’ on Android Studio.

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