我是新手。我使用 libgdx 项目生成器生成了一个新项目,一切正常。然后我尝试使用以下教程将 liquidfun 扩展添加到库中:https://github.com/finnstr/gdx-liquidfun-extension/wiki/Setup . 它编译在编辑器中看到的所有依赖项,但在运行时出现此错误。
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/badlogic/gdx/physics/box2d/World; 10-09 10:29:50.698 12790-12895/com.mygdx.game.android E/AndroidRuntime: at com.mygdx.game.MyGdxGame.createBox2DWorld(MyGdxGame.java:87)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.badlogic.gdx.physics.box2d.World" on path: DexPathList[[zip file "/data/app/com.mygdx.game.android-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mygdx.game.android-1/lib/arm, /vendor/lib, /system/lib]]
我对这部分为 Eclipse 制作的教程感到担忧。我不知道如何在 Android Studio 中配置它。
To do so you should right click on android project and select Properties -> Java Build Path -> Add external Jar and pick core/libs/gdx-liquidfun.jar. Last step is to check this library in Order and export.
注意:我还尝试加载 native 库,它们没有抛出任何错误。
static {
System.loadLibrary("gdx-liquidfun");
System.loadLibrary("gdx-box2d");
}
请您参考如下方法:
我想通了。我必须右键单击 jar 并添加为库。我不得不将 jar 复制到 android/libs。来自 core/libs 的那个没有添加为库的选项


