2

Using libgdx 1.7.0/Android Studio, TexturePacker is supposed to be included out of the box if checking the tools option when creating the project (and so I did).

In fact, if I check my build.gradle file, in the project(":desktop") section I have the compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion" added.

But even with that, the build is not able to find the tools package (even though I can successfully use the Controllers extension, which should be the same I think)

I'll leave here the desktop part of the build.gradle, just in case:

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-controllers-desktop:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
    }
}

And a image with the libraries in the project, where you can see the tools...

enter image description here

danikaze
  • 1,550
  • 2
  • 16
  • 34

2 Answers2

0

This is an issue caused by importing tools in Core Dependency. Remove the dependency in the project(":desktop") of the Core Dependency and add it to desktop dependency.

You can also solve it by downloading the gdx tools and importing the jar file. Just create a library folders and paste the jar file. Then go to File > Project Structure > Modules and add the File Dependency which is your jar file.

dependencies {
    compile files('libs/runnable-texturepacker.jar')
}

This should work fine.

Zack
  • 1,527
  • 2
  • 20
  • 32
  • well, yeah, it's the same method that I did with tweenengine, but isn't supposed to work out of the box from the installation if you check that option? (and that's why I have the dependencies...) – danikaze Dec 07 '15 at 11:09
  • @danikaze Try the first solution on the answer if you need to import from gradle this way. – Zack Dec 07 '15 at 15:48
0

I was trying to use the TexturePacker class within a class in the core module. However I discovered it to only be available in the desktop module. This seems logical as the dependency of the tools extension is placed within the desktop project in the root build.gradle file when using the setup utility or following the official instructions to add the extension manually (see Add tools dependency).

Technically, you could move the dependency in the module you want to use TexturePacker in (say core), but according to the provided link this is discouraged. So I recommend you just write your class using TexturePacker within the desktop module.

PS: Note that due to the deprecation of "compile" a replacement by "implementation" in build.gradle might become necessary, but Android Studio will inform you in that case (use ctrl + r for efficient replacements).

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
H.G.M.
  • 81
  • 1
  • 7