我在这里检查了其他问题和答案,但仍然无法弄明白。我正在使用安装了android sdk的eclipse并遵循Learning Libgdx游戏开发书。
游戏在桌面上工作正常,直到我进入第11章关于Box2D并且现在游戏菜单加载但是当我去玩它崩溃然后我得到了
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx-box2d.dll' for target: Windows 7, 32-bit
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:117)
at com.badlogic.gdx.physics.box2d.World.<clinit>(World.java:187)
... 20 more
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Unable to read file for extraction: gdx-box2d.dll
at com.badlogic.gdx.utils.SharedLibraryLoader.readFile(SharedLibraryLoader.java:126)
at com.badlogic.gdx.utils.SharedLibraryLoader.loadFile(SharedLibraryLoader.java:261)
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:115)
... 21 more
我在网上找到的一个答案是“你还必须为桌面添加包含本机库的工件”,请在此处找到Couldn't load shared library box2d for libgdx。
在我的核心项目中,我引用了具有gdx-box2d-1.5.3.jar的库,但在桌面上我没有。我尝试使用import导入它,并尝试将其添加为外部jar但仍然无效。如果已经回答了任何建议,我们将非常感激或指出正确的方向。
更新:我现在实际上在项目的桌面部分有gdx-box2d.jar,但仍然无法正常工作并在控制台中出现相同的错误。
由于
答案 0 :(得分:2)
Did you also reference gdx-box2d-natives.jar in your desktop project? Anyway, here's how my project libs are. Look at the box2d ones (except box2dlights).
Also after setting references, I know it will sound stupid, but do a project clean up and restart Eclipse if you're using it. I lost count of how many times I've tried to fix an error that was not supposed to happen in the first place, and got fixed after restarting Eclipse.
Eclipse is love. Eclipse is life.