Search code examples
libgdxbox2d

Physics Body Editor error


I get this error when trying to initialize BodyEditorLoader from this library http://www.aurelienribon.com/blog/projects/physics-body-editor/

    Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.UnsatisfiedLinkError: com.badlogic.gdx.physics.box2d.PolygonShape.newPolygonShape()J
        at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:127)
    Caused by: java.lang.UnsatisfiedLinkError: com.badlogic.gdx.physics.box2d.PolygonShape.newPolygonShape()J
        at com.badlogic.gdx.physics.box2d.PolygonShape.newPolygonShape(Native Method)
        at com.badlogic.gdx.physics.box2d.PolygonShape.<init>(PolygonShape.java:29)
        at aurelienribon.bodyeditor.BodyEditorLoader.<init>(BodyEditorLoader.java:31)

How can i fix it?


Solution

  • Based on this https://github.com/libgdx/libgdx/issues/2393 the problem is because natives aren't loaded before creating shape.

    There are two solutions:

    First is creating World instance before creating any shapes.

    Second is calling Box2D.init(); before creating any shapes. This method is preferred because you don't need to create World instance and it's much more obvious.

    Use this version https://gist.github.com/grulg/8691e7ee7709367ce165 instead of version from Google Code.