user2052752 user2052752 - 1 month ago 6x
Java Question

Trouble adding a tools dependency with Gradle for LibGDX

I'm following along in Learn LibGDX Game Developer 2nd Edition for a class. I'm using Eclipse. We're making a game for the desktop (Android and all disabled). We used Gradle as well. I come to this paragraph...

For Gradle users, adding gdx-tools is easy; we just need to add the
following highlighted line to the build.gradle file in C:/libgdx:

project(":desktop") {
compile "com.badlogic.gdx:gdx-tools:$gdxVersion"

Make sure that you are editing under the section project(":desktop").
After editing, we need to refresh our dependencies. To do this,
right-click on the CanyonBunny-desktop project and go to the Refresh
All option in the Gradle menu. Make sure that you are connected to the
Internet because Eclipse will download the relevant dependencies.

My build.gradle under project(":desktop") method is the following...

project(":desktop") {
apply plugin: "java"

dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
compile "com.badlogic.gdx:gdx-tools:$gdxVersion"

I also just built a dummy LibGDX project with tools enabled to make sure I was adding the code to the right section, which I was.

After doing that, I refreshed gradle by right clicking my dependency Gradle (STS) -> Refresh All

Now when I add in some imports from that tools dependency I thought I added, my runner class cannot find it.


Any help? Let me know if you need more info, I tried to be as detail as possible!


The book has a typo, it is suppose to be...

compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"