Dr NotSoKind
Dr NotSoKind

Reputation: 225

Can't start a libgdx desktop project

I'm developing an Android application with Libgdx. Everything has gone good so far (I've been debugging in the emulator), but I came to a point where I needed to set up a desktop project, so I could test the app faster (so instead of running it on an emulator, I could test it on a desktop app).

I made the setup just as the wiki says, adding the desktop version, and everything has gone good so far, no compiler errors. But when I try to launch the desktop app, I get the following error, without even opening a window:

Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/Net
    at DesktopGame.main(DesktopGame.java:12)
Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.Net
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)

The line 12 of the DesktopGame.java says:

new LwjglApplication(new UserStart(userID, appDefinitions), "Game", 1024, 600, false);

Where UserStart is the ApplicationListener (with a custom constructor as I needed a couple of parameters, this setup works well on Android). I don't know why com.badlogic.gdx.Net is not found (and I don't know why it is looking for it as I'm not using network features).

Does anyone know what could it be? Thanks!

Upvotes: 1

Views: 7602

Answers (2)

SoftRock
SoftRock

Reputation: 96

I just added the gradle plugin for the eclipse and my problem was solved. Gradle plugin can be added by following the instructions on this link http://estiloasertivo.blogspot.com/2013/03/tutorial-howto-install-and-configure.html

Upvotes: 0

Dr NotSoKind
Dr NotSoKind

Reputation: 225

Solved it! Well, kind of. I created a new project using the setup UI from libgdx, and then copied the created desktop project to my own project. I noticed that the main difference was on which constructor I was using for the LwjglApplication, now in this case, instead of passing the parameters, I called the constructor with a LwjglApplicationConfiguration:

LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "MyGame";
cfg.useGL20 = false;
cfg.width = 480;
cfg.height = 320;

...
new LwjglApplication(new UserStart(userID, appDefinitions), cfg);

Yay! I'm not sure if this was the main issue, but at least now works.

Thanks everybody for the comments and tips.

Upvotes: 3

Related Questions