views:

3537

answers:

5

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?

Thank you for your time.

+2  A: 

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
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
+1  A: 

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/

sehugg
Cool - I'll take a look after work
Marc
A: 

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  A: 

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

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

John
+1  A: 

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