21

I've looked around for a physics engine that will play nicely with Android, but I've only been disappointed.

In terms of performance, I had heard that jbox2d was the best bet, but (from my understanding) ever since Android SDK V1.0, the Dalvik VM's verifier has become very strict and rejects some of the key classes and refuses to run. This problem persists after using the dx tool (although I might be using the tool improperly).

I know that the AndroidBox2D porting project exists to optimize jbox2d for the Android garbage collector, but the project page doesn't have any downloads and the gpl license isn't as attractive as the zlib license of the original.

Does anyone have any tips for making jbox2d work in Eclipse, or have any recommendations for where I should start looking?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Marc
  • 2,593
  • 2
  • 18
  • 21
  • Now that the NDK is out, this abox2d (android NDK version of Box2D) was insanely easy to get working: http://groups.google.com/group/android-ndk/browse_thread/thread/10f2e02c5d6857cb?pli=1 But note that you have to add a few headers when developing under linux – Marc Jul 13 '09 at 12:44
  • 2
    Since I asked this question, AndEngine has made a lot of progress. You might want to check it out here: http://code.google.com/p/andengine/ – Marc Nov 11 '10 at 13:58
  • Voting to close as tool rec. – Ciro Santilli OurBigBook.com Apr 29 '16 at 09:44

6 Answers6

3

I don't know why Dalvik would reject classes unless they were obfuscated with some tool. Did you try recompiling Box2d from source?

The only other Java lib I've seen is http://www.cokeandcode.com/phys2d/

sehugg
  • 3,615
  • 5
  • 43
  • 60
  • From what I've gathered on forums, Dalvik is rejecting the classes due to type safety restrictions. And yup, compiling from source gives the same. But Box2d seems to work (so far running the springytest without rendering, at least). Thanks – Marc Jun 24 '09 at 03:53
2

I am getting good results with the Java version of APE using Fixed Point math rather than floats.

http://www.cove.org/ape/

John
  • 21
  • 1
2

I have done an implementation of the APE engine now using (mostly) fixed point math and it is without garbage collection. Its a pretty nice engine to do stuff with constraints but seems less suited for really rigid bodies.

http://code.google.com/p/ape-physics-for-android/

You could also look into the NDK port of Chipmunk (download link on youtube page)

http://www.youtube.com/watch?v=_i_GFjfmLTc

Michiel
  • 270
  • 1
  • 3
  • 11
1

Also look @ Glaze which is optimized for arrays .. might not be a horrible port to Java from AS3 (it was ported to Haxe also)

http://code.google.com/p/glaze/

Gama11
  • 31,714
  • 9
  • 78
  • 100
sehugg
  • 3,615
  • 5
  • 43
  • 60
0

Libgdx has JBox2D built in and is cross platform (Android, Java Desktop, GWT Web) like Unity, tho it's free and open source.

I got it set up in 15 minutes and was creating physics bodies in no time. The Libgdx physics manual helps from there. Good luck!

Brad
  • 150
  • 1
  • 5
0

I am not sure, if jBox2D is really suitable for smartphones. I would rather look at J2ME engines, as they are highly optimized for performance- E.g: http://emini.at

Also you should have no problems with integration.

deneb
  • 1
  • 1