java.lang.NoClassDefFoundError when running libgdx sample gdx-invaders for desktop

心已入冬 提交于 2019-12-11 02:48:24

问题


I'm building libgdx's gdx-invaders sample. There are two projects: gdx-invaders - the base project, which runs as a desktop Java application gdx-invaders-android project - depends on gdx-invaders, and runs as an Android application

I'm new to Eclipse, but based on the best tutorials I could find, took the appropriate steps to get these two projects referencing the appropriate libraries (gdx.jar, etc.), and to get them using Android 2.2. I also tried basic fixes like cleaning before building, and restarting Eclipse.

Now, gdx-invaders builds, but when it runs, I get this runtime exception:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gwt/core/client/GWT
    at com.badlogic.gwtref.client.ReflectionCache.<clinit>(ReflectionCache.java:24)
    at com.badlogic.gdx.utils.reflect.ArrayReflection.newInstance(ArrayReflection.java:11)
    at com.badlogic.gdx.utils.Array.<init>(Array.java:64)
    at com.badlogic.gdx.backends.openal.OpenALAudio.<init>(OpenALAudio.java:51)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:82)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:64)
    at com.badlogic.gdxinvaders.GdxInvadersDesktop.main(GdxInvadersDesktop.java:27)

And gdx-invaders-android does not build at all - it is unable to reference package com.badlogic.gdxinvaders (a package which is defined in gdx-invaders), which results in compiler errors when attempting to reference GdxInvaders, a class defined in that package.

The build libraries are from a libgdx-nightly-latest distribution. Do you guys have a preference of whether it's better to copy JARs from here into my base project's lib directory, and reference the JARs here with Add Jars, or whether it's better to use Add External JARS and reference them in the libgdx-nightly-latest directory?

Thanks!! Aaron


回答1:


You have to add gdx project into your project tab which is in java build path. You have to include jpct_ae.jar and jpct_shaders.zip into your project build path.



来源:https://stackoverflow.com/questions/19000556/java-lang-noclassdeffounderror-when-running-libgdx-sample-gdx-invaders-for-deskt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!