0

我想开始开发安卓游戏,所以我试图用 IntelliJ 设置 libGDX。我使用wiki 中的此链接来设置所有内容,但它不起作用。

它说我缺少一个库,但它们存在于类路径中,并且所有模块依赖项都已正确设置。

我错过了什么吗?

这是堆栈跟踪:

Exception in thread "main" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'libgdx.dylib' for target: Mac OS X, 32-bit
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:104)
at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:34)
at com.badlogic.gdx.backends.lwjgl.LwjglNativesLoader.load(LwjglNativesLoader.java:46)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:76)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:64)
at it.enrichman.game.DesktopStarter.main(DesktopStarter.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.NullPointerException
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:102)
... 10 more

这些模块中的类:

安卓:

public class MySimpleGameTest extends AndroidApplication {

  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
      cfg.useAccelerometer = true;
      cfg.useCompass = false;
      cfg.useWakelock = true;
      cfg.useGL20 = true;
      initialize(new TestGame(), cfg);
  }
}

桌面:

public class DesktopStarter {
  public static void main(String[] args) {
      LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
      cfg.title = "Title";
      cfg.useGL20 = true;
      cfg.width = 800;
      cfg.height = 480;
      new LwjglApplication(new TestGame(), cfg);
  }
}

和主要:

public class TestGame extends Game {

Texture carImage;

  @Override
  public void create() {
      carImage = new Texture(Gdx.files.internal("car.png"));
  }
}
4

1 回答 1

0

你必须在导入 gdx.jar 之后导入库 gdx-natives.jar,我遇到了同样的问题。

于 2013-08-15T12:39:31.927 回答