libGDX with Gradle -> how to install?

Okay, I used libGDX always with the complete Source, now I try it with Gradle and I failed terribly.

I am using IntelliJ.

I generated an new Project with the libGDX Project Setup and I need Gradle to resolve the libGDX dependencies.
And well, … it´s not working.

I tried to import the Project directly with the build.gradle.
I settet in the Project Settings the Module Dependencies to Gradle Wrapper.
I created an 2nd Project.
I run and created the build.gradle
It has the same project tree like described at the libGDX Homepage.

But IntelliJ is not resolving the libGDX Libs.

What else do I have to do?

Well I just use the gradle wrapper that’s included when you create a project. So go to your project dir and just do the old “gradlew idea” or “gradlew eclipse” depending on your GUI. That will generate the project files for you.

This is, in my opinion, a lot faster than using the gradle build in your IDE. Compile time is a lot slower when you do the gradle build, last I tested.

Ah, but the price of Gradle outweighs the marginally slower compile time (you should not be seeing any slower times at all, actually). The ability to transfer your project to anywhere and to be able to execute a script which sets up your entire project for you is immensely useful.

Ehh, what do I have to do now if I want to use Gradle?

I’m sure any problems were resolved by now given the age of this thread. But if someone in the future runs into trouble with LibGDX and IntelliJ, there is this very helpful youtube channel (gamesfromscratch) that explains how to set it up:

It targets older versions, but the setup steps should be the same. If there is a problem there is also this more recent video which goes beyond only the setup steps:

Historically I’ve been against youtube/twitch for programming given that watching somebody type is almost just as boring as watching grass grow, but in the case of game programming with high level tooling where you get a lot done with less code I’m enjoying the merits of seeing it happen rather than only having it explained in words and screenshots.