我希望开始开发Android游戏,所以我试图用IntelliJ设置libGDX。 我使用了wiki中的this link来设置所有内容,但它不起作用。
它说我缺少一个库,但它们存在于类路径中,所有模块依赖项都设置正确。
我错过了什么吗?
这是堆栈跟踪:
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);
}
}
和Main:
public class TestGame extends Game {
Texture carImage;
@Override
public void create() {
carImage = new Texture(Gdx.files.internal("car.png"));
}
}
答案 0 :(得分:0)
导入gdx.jar后必须导入库gdx-natives.jar,我遇到了同样的问题。