2013-08-26 60 views
5

我正在与LibGDX在桌面上的问题。我不断收到试图启动应用程序时出现以下错误:UnsatisfiedLinkError Libgdx桌面

Exception in thread "main" java.lang.UnsatisfiedLinkError: com.badlogic.gdx.utils.BufferUtils.newDisposableByteBuffer(I)Ljava/nio/ByteBuffer; 
at com.badlogic.gdx.utils.BufferUtils.newDisposableByteBuffer(Native Method) 
at com.badlogic.gdx.utils.BufferUtils.newUnsafeByteBuffer(BufferUtils.java:288) 
at com.badlogic.gdx.graphics.glutils.VertexArray.<init>(VertexArray.java:62) 
at com.badlogic.gdx.graphics.glutils.VertexArray.<init>(VertexArray.java:53) 
at com.badlogic.gdx.graphics.Mesh.<init>(Mesh.java:148) 
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:173) 
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:142) 
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:121) 
at com.badlogic.gdx.graphics.g2d.SpriteBatch.<init>(SpriteBatch.java:115) 

我有以下库添加到我的项目:

  • gdx.jar
  • GDX-sources.jar
  • GDX-natives.jar
  • GDX-后端-lwjgl.jar
  • GDX-后端-LWJGL-natives.jar

我错过了什么吗?

我已经搜索了高低,但我发现的一切都是为了Android,并告诉我将arm文件夹中的.so库添加到我的项目中,但对于我在wintel上的桌面项目没有任何意义平台。

+1

它不必位于*类路径*它必须位于*库路径*中,这意味着您必须通过将其值设置为目录的路径来定义java.library.path系统属性这样的文件驻留。无论是从命令行或编程,但那么它必须是在这之前的代码试图执行或[UnsatisfiedLinkError抛出](http://docs.oracle.com/javase/7/docs/api/java/lang/UnsatisfiedLinkError.html )。根据[libgdx是](https://code.google.com/p/libgdx/)来判断我建议你从@ noone的回答中尝试解决方案。 – linski

回答

15

我建议你用this GUI来设置你的项目。它应该为您提供适用于所有平台的有效设置。您也可以使用最新的每晚构建并检查问题是否仍然存在。问题可能是本地库与其他罐子不匹配。

另一个问题可能是你实例化了一个SpriteBatch(或其他内部使用SpriteBatch的东西)太早(在stacktrace中看起来有点像这样)。例如静态像这样:

private static SpriteBatch batch = new SpriteBatch(); 

这是行不通的,因为libgdx没有正确设置在这个时间点。相反,请在您的游戏的create/show方法中创建此类事物。

+8

我很确定它的第二个答案(SpriteBatch构造函数在Libgdx初始化之前被调用)。 –

+0

后者是这种情况。谢谢! – jonbonazza

+0

我在我的游戏对象的构造函数设置屏幕犯了这个错误,而不是我的游戏对象的方法#创建。第二个答案对此有意义。 – Moz

相关问题