LonamiWebs/Klooni1010

Can't run build jar due to java.lang.NoClassDefFoundError

raLaaaa opened this issue · 6 comments

Hey there,

I imported the project to my IntelliJ.
Afterwards I ran the ./gradlew desktop:dist command from the root project folder.
Output states that the build has been succesfull.

Afterwards I run the build .jar with java -jar xxx.jar

It then states the following exception;

java.lang.NoClassDefFoundError: com/badlogic/gdx/ApplicationListener (sounds a little bit like my system can't find libgdx in the build .jar)

When trying trying to start the DesktopLauncher manually via my IDE the following exception comes up:

Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: ic_launcher\icon128.png (Internal)

I'm using newest IntelliJ Community Edition, Java 9 and build in Intellij Gradle. Any ideas why this happens? I'm assuming that it's a problem on my side.

Help or hints are much appreciated! Thanks for your work.

Maybe we shouldn't update gradle. See this answer on java.lang.NoClassDefFoundError (libgdx).

Ah thanks for the reply. What a pity.

I've re-ran the setup and used those files, pushed in commit 9c6be35. Could you try again? I've seen some fixes for the weird things one had to do before to change the assets location, so hopefully it's less of a pain to run now.

Thanks for your help. It still doesnt work but if i try to run the build application it now also displays the following exception (similiar to running the desktop launcher directly via IDE):

It can find the application listener though. So I think it's a step towards the right direction?

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: ic_launcher/icon128.png

It's weird it still fails like that. Note this line of the mentioned commit, it points to the android/assets folder which contains the ic_launcher/icon128.png file. I'm not sure why it's failing right now.

As a workaround you could try to copy the assets folder to whatever working directory you are on when running, but I haven't had that issue.

Copying assets in the working directoy fixed it for me! No idea why it exactly did not work though. Thanks for the help!