UnsatisfiedLinkError Libgdx Desktop

◇◆丶佛笑我妖孽 提交于 2019-12-19 19:04:17

问题


I am running into issues with LibGDX on Desktop. I keep getting the following error when trying to launch the application:

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)

I have the following libraries added to my project:

  • gdx.jar
  • gdx-sources.jar
  • gdx-natives.jar
  • gdx-backend-lwjgl.jar
  • gdx-backend-lwjgl-natives.jar

Am I missing something?

I have searched high and low, but everything I find is for Android and tells me to add the .so libs from the arm folders to my project, but that doesn't make sense to me for a desktop project on wintel platform.


回答1:


I'd advise you to setup your projects with this GUI. It should provide you with a valid setup for all platforms. You may also use the latest nightly builds and check if the problem still occurs. The problem might be that the native libraries do not match the other jars.

Another problem might be that you instantiate a SpriteBatch (or something else which internally uses a SpriteBatch) too early (looked a bit like this in the stacktrace). For example statically like this:

private static SpriteBatch batch = new SpriteBatch();

This won't work, since libgdx wasn't setup correctly at this point in time. Instead, create such things in the create/show methods of your game.



来源:https://stackoverflow.com/questions/18436344/unsatisfiedlinkerror-libgdx-desktop

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