libgdx / libgdx

Desktop/Android/HTML5/iOS Java game development framework
http://www.libgdx.com/
Apache License 2.0
23.16k stars 6.42k forks source link

LWJGL3: File not found: sprites\sprites.atlas (Internal) #6266

Closed GlennFolker closed 3 years ago

GlennFolker commented 3 years ago

Issue details

AssetManager says that sprites.atlas can't be found when game is run, even though I have packed the sprites to correct directory.

Reproduction steps/code

The code is here. To build, cd to root directory and run:

$ gradlew.bat tools:packSprites
$ gradlew.bat desktop:dist

Then, cd to ./desktop/build/libs, and run:

$ java --enable-preview -jar Innerclash.jar

Game window opens, then closes due to crash. A crash log should appear in %APPDATA%\Innerclash\crashes.

Note that this project is made for Java 15.

Version of LibGDX and/or relevant dependencies

libGDX version is 1.9.12, and I only use gdx-tools, gdx-backend-lwjgl3, gdx-platform, and gdx-controllers-lwjgl3.

Stacktrace

Here's the crash log from a generated file:

Innerclash has crashed!
How could this be?

Stacktrace:
com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: File not found: sprites\sprites.atlas (Internal)
    at com.badlogic.gdx.assets.AssetManager.handleTaskError(AssetManager.java:634)
    at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:413)
    at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:425)
    at innerclash.ICLauncher.update(ICLauncher.java:63)
    at innerclash.ICLauncher.render(ICLauncher.java:103)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:403)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:141)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:117)
    at innerclash.desktop.DesktopLauncher.main(DesktopLauncher.java:17)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: sprites\sprites.atlas (Internal)
    at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:142)
    at com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData.<init>(TextureAtlas.java:104)
    at innerclash.graphics.ICTextureAtlas$ICTextureAtlasLoader.getDependencies(ICTextureAtlas.java:101)
    at innerclash.graphics.ICTextureAtlas$ICTextureAtlasLoader.getDependencies(ICTextureAtlas.java:74)
    at com.badlogic.gdx.assets.AssetLoadingTask.handleSyncLoader(AssetLoadingTask.java:99)
    at com.badlogic.gdx.assets.AssetLoadingTask.update(AssetLoadingTask.java:89)
    at com.badlogic.gdx.assets.AssetManager.updateTask(AssetManager.java:561)
    at com.badlogic.gdx.assets.AssetManager.update(AssetManager.java:411)
    ... 7 more

Sidenotes

I am very new to both Java programming and using libGDX, I would be really grateful if you could help me. Sorry to waste your time. I'll be back tomorrow.

Please select the affected platforms

tommyettinger commented 3 years ago

Unfortunately, gdx-tools is only compatible with the lwjgl backend ("desktop", not lwjgl3) if used at runtime. People usually pack atlases independently of their project using either a tool like the free Texture Packer GUI or the command-line version of gdx-tools' texture packer. If they pack in code, they have to either have a separate module that depends on gdx-tools and the lwjgl, AKA desktop, backend (which is a good idea, since it means your distributable JARs are a little smaller), or use lwjgl throughout, or use PixmapPacker to pack editable images at runtime. PixmapPacker is part of libGDX, not gdx-tools, so it works with LWJGL 2 and 3, plus Android, iOS, etc.

I'll take a look at your code, since there are ways you can use gdx-tools with LWJGL3 by excluding some of its features. If you've done that, then the error could be caused by something very different.

tommyettinger commented 3 years ago

Well, a full error log sure would have helped...

> Task :tools:packSprites FAILED
Exception in thread "main" java.lang.NoClassDefFoundError: innerclash/Innerclash
        at innerclash.tools.SpritePacker.<init>(SpritePacker.java:30)
        at innerclash.tools.SpritePacker.main(SpritePacker.java:25)
Caused by: java.lang.ClassNotFoundException: innerclash.Innerclash
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        ... 2 more

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\Downloads\Innerclash\Innerclash-master\tools\build.gradle' line: 24

You've done some very strange setup that I do not feel I can fix, since you are depending on your Innerclash class (in the main project) from the tools project's buildscript. The buildscript parts of gradle are... odd, and I have never used them much. I really need to recommend crashinvaders' GDX Texture Packer GUI again; it should make the tools project unneeded. It actually looks like you might just be breaking up an image into a grid of sections, which TextureRegion can do on its own.

That said, this is not a bug in libGDX, it's a bug in your Gradle configuration, so this is not the right place for this. The discord may be more suitable.

GlennFolker commented 3 years ago

Why didn't that happen to me

GlennFolker commented 3 years ago

Forget it, I'm joining the discord