Pasha
Pasha

Reputation: 279

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?

Upvotes: 9

Views: 7708

Answers (5)

Vladyslav Vlad
Vladyslav Vlad

Reputation: 1

I got the same problem. My solution is - go Project/Structure, search gdx library by name "gdx", add this library to your project, and then you'll be able to add gdx-tools to your build.gradle.

Upvotes: 0

jwehrle
jwehrle

Reputation: 4784

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.

Upvotes: 2

Deepscorn
Deepscorn

Reputation: 832

If you use modern IDEA or Android Studio, then any time you need new dependency to be downloaded, just add

compile "group:artifact:version"

inside dependencies {} section (like you've done), click "Sync project with gradle files"

and wait for gradle build/indexing to finish.

Also, in your case, check that $gdxVersion is correct. You must have something like:

buildscript {
    ext {
        gdxVersion = '1.6.0'
    }
}

You can also create a task in your project just to print it:

task someName << {
  println $gdxVersion
}

then call it from command line:

./gradlew -q someName

Also you can check out that repo - it has optimized gradle files, so it builds somewhat faster. At least it was so, I don't watch what the libgdx guys were doing for some time

Upvotes: 0

Nico Km
Nico Km

Reputation: 23

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!

Upvotes: 1

nounoursheureux
nounoursheureux

Reputation: 175

Did you use the gdx-setup.jar file to create your project ? You can find it in the wiki, it is the official way to create a new project

Upvotes: -1

Related Questions