LibGDX Tutorial – Part 4

Importing the Project

As we have succesfully created a sample project using the LibGDX setup app, let’s start working on it. We’re going to import the project into IntelliJ Idea. You can also use Eclipse instead but the recommended tool is IntelliJ. You’re supposed to have properly setup the development environment before importing the project.

Right! Now we’re all set, let’s go ahead and open IntelliJ Idea. If you’re opening it for the first time, a Welcome window will be shown. Before importing the project, let’s setup some common project properties.

Default Project Structure

Click on the Configure button (gear icon) on the bottom right side and go to Project Defaults -> Project Structure. This is the Default Project Structure window. Here you can add common SDKs that will be used like Android SDK and JDK. To add them, first make sure that you’re in Project Settings -> SDKs tab. Then click on + icon at the top.

Screenshot - Saturday 23 July 2016 - 12:34:13  IST

Choose JDK first and select the directory where JDK is installed (parent of bin directory). Then you’ll be asked to choose the JDK version to be imported.

Now let’s add the Android SDK. Click on the + button again and choose Android SDK. Like we did before, select the Android SDK path and choose the Android version you want to import.

Note: This is a one time thing. You don’t have to do it for subsequent projects.

After adding them both, you can see that they are listed in the SDK list. Click OK.

Project Import

We’ve successfully setup the default project properties and now we can import the project. Click on Import Project and navigate to the directory where the project was created during setup. There will be a build.gradle file inside the project root directory. This is the file we need to import the project.

Screenshot - Saturday 23 July 2016 - 12:50:45  IST

If you want to know more about Gradle files and what it does, you can start here in this SO question where it’s explained in simple terms. Basically it’s a build system and there are different tasks mentioned in the file that needs to be executed. So in our build.gradle file, there are different commands for IntelliJ Idea to properly import the project and run it. The whole project is built around Gradle system.

After selecting the build.gradle file, a new window will be opened where you can select the gradle files location and JDK paths if necessary. But we don’t want to make any changes here. Just click Next.

In newer IntelliJ Idea versions, you will be asked to choose which all gradle files to be imported. Each module has it’s own gradle file and there’s a root gradle also. We should import all of them.

Screenshot - Saturday 23 July 2016 - 01:02:54  IST

Likewise, another window will be shown to remove the unused gradle projects. Check the default projects and click OK. These will be removed from our project. This is some sort of cleaning up process in newer IntelliJ Idea versions. I’ll write about it if I come to know in detail what it does.

That is all. We have successfully imported a new project in IntelliJ Idea created using the LibGDX setup app. In the next tutorial, we can run this project and see what it does.

Love Peace.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s