We finished moving Box2D out of core and into an extension, just like our Bullet extension. The reason for this move was that not everyone needs Box2D, and it adds quite a bit of additional size to your packages. No more! Let’s see how you can add Box2D to your projects from now on.
New Gradle-based Project
If you use our new Gradle-based setup, you simply check the “Box2D” box and generate your project. All will be set up for you!
Existing Gradle-based Project
Existing Gradle-based projects must add Box2D as a dependency to their build.gradle file and then refresh their IDE projects. See this wiki article on what do add to your build.gradle file.
Existing Eclipse projects
Old school projects generated by the old setup UI for Eclipse will have to add Box2D manually. Download the nightlies (or the 1.0 release in a few days), and copy the following file form “extensions/gdx-box2d” to your project:
- gdx-box2d.jar to your core project’s libs/ folder. Add it to the project’s build path, and make sure it is exported
- gdx-box2d-natives.jar to your desktop project’s libs/ folder. Add it to the project’s build path.
- armeabi/libgdx-box2d.so to your android project’s libs/armeabi folder, armeabi-v7a/libgdx-box2d.so to the libs/armeabi-v7a folder and x86/libgdx-box2d.so to the libs/x86 folder.
- gdx-box2d-gwt.jar to your HTML project’s libs/ folder. Add it to the project’s build path. Do the same for the gdx-box2d-gwt-sources.jar file. You will also need to add
<inherits name='com.badlogic.gdx.physics.box2d.box2d-gwt' />to your gwt.xml file
- ios/libgdx-box2d.a to your iOS project’s libs/ios folder. Add an entry to your robovm.xml file, just like there’s one for libgdx.a.