Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't add gdx-tools to libgdx gradle project

I'm new in Gradle. I'm trying to add gdx-tools to my project:

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-tools:$gdxVersion"
    }
}

I open my Desktop project, folder "Gradle Dependecies" and see "gdx-tools-1.0.1.jar". As I try to open it - nothing shows.

So, when I try to use it ( I want to try pack images to atlas) - I can't import com.badlogic.gdx.tools...

What I do wrong?

like image 394
Pasha Avatar asked May 19 '14 16:05

Pasha


2 Answers

I had the same problem. So I put "com.badlogicgames.gdx:gdx-tools:1.9.2" into my browser to see where it took me. (1.9.2 being my gdxVersion) Sure enough it did not take me to a page but to a search result. I followed the first one:

http://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx-tools/1.5.2

Which says there is a new version - 1.9.2 (well, duh - that's what I'm trying to reach. Thankfully, there's a link and I follow it.)

http://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx-tools/1.9.2

Now, in the upper center of the page you'll see a tabbed box with code in the middle. Select Gradle and copy that code.

Back in your Gradle file add:

compile (paste)

Or, in my particular case:

compile 'com.badlogicgames.gdx:gdx-tools:1.9.2'

Now hit sync. This worked but I was worried about hard coding the gdxVersion number so I played around. If you replace the 1.9.2 with $gdxVersion and the single quotes (') with double quotes (") it should sync. So now my Gradle line looks like this:

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

Why? This seems identical to the version I tried first. I don't know. But these are the steps that led to a successful sync for me.

like image 158
jwehrle Avatar answered Nov 12 '22 01:11

jwehrle


On this site they give you a detailed explanation on how to update your dependencies.

https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle#tools-gradle

After you put in what they say in the gradle, right click on your project and do gradle -> refresh dependencies.

I don't know if it really helps, but hopefully it can help someone!

like image 1
Nico Km Avatar answered Nov 12 '22 00:11

Nico Km