线程中的异常 "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.ExceptionInInitiali



i'm a beginner programmer and need some help. I'm using android studio and libgdx. I created a project. When I try to use box2d", I get this error:

"线程中的异常";LWJGL应用";com.badlogic.gdx.utils.GdxRuntimeException:java.lang.ExceptionInInitializerError">

Whenever I run a LibGDX project that uses box2d I always get a "java.lang.ExceptionInInitializerError" at the line where I initialize the world. I am just learning it in a tutorial series. I am trying to make am image into a physics body so it can fall. I think the problem may have something to do with the version of libGDX and android studio that I am using. Maybe both of them don't go too well. Please I would appreciate your help. Thank you.

public class MainGame extends ApplicationAdapter {

@Override
public void create() {
texture = new Texture("badlogic.jpg");
spriteBatch = new SpriteBatch();
sprite = new Sprite(texture);
world = new World(new Vector2(0, -98f),true);
body = createBody();
PolygonShape shape = new PolygonShape();
shape.setAsBox(sprite.getWidth()/2,sprite.getY()/2);
FixtureDef fixtureDef  = new FixtureDef();
fixtureDef.density = 1f;
fixtureDef.shape = shape;
Fixture fixture = body.createFixture(fixtureDef);
shape.dispose();
}
}

当我运行程序时,我的logcat中的错误如下所示

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.ExceptionInInitializerError
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:135)
Caused by: java.lang.ExceptionInInitializerError
at com.ikedinachim.com.MainGame.create(MainGame.java:31)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:151)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:128)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx-box2d64.dll' for target: Windows 10, 64-bit
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:125)
at com.badlogic.gdx.physics.box2d.World.<clinit>(World.java:187)
... 3 more
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Unable to read file for extraction: gdx-box2d64.dll
at com.badlogic.gdx.utils.SharedLibraryLoader.readFile(SharedLibraryLoader.java:133)
at com.badlogic.gdx.utils.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:289)
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:121)
... 4 more

如果您自己设置所有内容,则必须将gdx-box2d-nactives.jar添加到桌面项目的libs目录中。

相反,我建议您使用libGDX设置应用程序来创建一个包含所有依赖项设置和IDE集成的框架项目,然后您就可以在其中进行编程,而不必担心会摆弄库。

https://libgdx.badlogicgames.com/download.html

相关内容

  • 没有找到相关文章

最新更新