Bullet and Android and Eclipse

Hello all,

I have looked through the forums and haven’t had much luck getting native bullet working with JME3.

I have tried to compile the test programs published by mikegriffin and einnor.

With einnor’s example (http://hub.jmonkeyengine.org/groups/android/forum/topic/is-android-viable/?topic_page=2&num=15#post-141272), I have imported the code into Eclipse, compiled it and installed it onto my Android phone. Unfortunately, I only get 1-2 fps. If I install his .apk, 60-70 fps.

Is anyone able to provide me with a step by step guide to compile einnor’s example or how to compile Android apps using native bullet?

Many thanks!!!


There is no such thing as an android binary of the latest version. Totally not supported yet, you’re on your own.

@glaucomardano and @normen

OK, I probably phrased my question incorrectly.

In a nutshell, I want to build this —> http://hub.jmonkeyengine.org/groups/android/forum/topic/is-android-viable/?topic_page=2&num=15#post-141272

Whenever I build the aforesaid, I get 1-2 fps. But if I install the .apk, I get 70-80 fps.

How do I build einnor’s example using Eclipse?

I think the problem is that libulletjme.so (which was built with Android NDK) isn’t being used and that jME3-bullet.jar is being used instead.

You probably included jME3-jbullet.jar, yeah. Still, that binary of bullet isnt working completely.

Yep I included jME3-jbullet.jar

I read on one of your other posts that this isn’t working properly and runs slow etc because there’s not a proper JIT compiler (if I recall correctly!)

However, I needed to include that library otherwise einnor’s example would not compile.

My expectation was that jME3-jbullet.jar would not be needed if libbulletjme.so was included but it doesn’t seem to be the case… but my guess is that the problem is me not the example code



Yes. When I removed the jME3-jbullet.jar it stopped working.

The referenced jars I used were





The compiled android libs are in the lib folder

libbulletjme.so is in the libs folder

The important line in the code to get the libbulletjme.so working is

static {




If you’ve imported the project from einnor I suspect you might have the same performance issue i had on one of my devices.

Using “eglConfigVerboseLogging = false;” seemed to boost performance about 5-10 times, giving playable fps.

@mikegriffin and @sigved thanks for your comments guys

I’ve given up on trying to get einnor’s example working

I am trying to get an example working from scratch as we speak

So far I have compiled the latest bullet (ver 2.79) as a native library using the NDK and the engine is loading up.

Might try mikegriffin’s ragdoll example :slight_smile: Will let you know how I go :slight_smile:

i think i have worked out what the problem is

it works with jME3 alpha-4 but not jME3 nightly (2011 10 21)

if I use jME3 nightly, I get initUserPointer:java.lang.UnsatisfiedLinkError!



Native bullet does work with JME3 Beta

This is a quick HOWTO :)

1. svn checkout jme3 beta source
2. download bullet 2.79 source
3. copy the jme3 native bullet source (i.e /src/bullet/native) to your jni folder in your project
4. extract the bullet 2.79 source in a subdir in your jni folder
5. create an Android.mk file compiling all *.cpp files
6. edit jmePhysicsSpace.cpp copied into your jni folder. The method jmePhysicsSpace::attachThread() needs to be modified to read

void jmePhysicsSpace::attachThread() {
vm->AttachCurrentThread(&env, NULL);

7. use ndk-build to build the files in your jni folder
8. if you haven't already done so, compile the jme3 beta source you checked out
9. include engine/dist/opt/android/jMonkeyEngine3.jar and /engine/dist/opt/native-bullet/lib/jME3-bullet.jar in your build path

Your native bullet engine should now work :)
@kentsusai said:
6. edit jmePhysicsSpace.cpp copied into your jni folder. The method jmePhysicsSpace::attachThread() needs to be modified to read

That bit got a fix in the latest version (which is in beta with all updates) and should compile on android as well as desktop. Could you maybe post the android binary of the latest version in /branches/3.0beta so we can integrate it and people don't have to search around or build it themselves?

ooo really?

I shall test again and let you know :slight_smile:


Compile++ thumb : bulletjme <= jmePhysicsSpace.cpp
mobile/jni/jmePhysicsSpace.cpp: In member function 'void jmePhysicsSpace::attachThread()':
mobile/jni/jmePhysicsSpace.cpp:52: error: invalid conversion from 'void**' to 'JNIEnv**'
mobile/jni/jmePhysicsSpace.cpp:52: error: initializing argument 1 of 'jint _JavaVM::AttachCurrentThread(JNIEnv**, void*)'
make: *** [mobile/obj/local/armeabi/objs/bulletjme/jmePhysicsSpace.o] Error 1

if I change the cast type from void** to JNIEnv**, it compiles

Man, what else can android mess up? :frowning: Its the correct signature for JNI1.2… Okay, I’ll change that then.


Once those changes are made, what would you like me to upload and where? Android.mk, Application.mk and .so files?

Something like that yeah. Does the compilation work with the internal tools of the SDK and Eclipse only? I never compiled anything native for Android myself as I have no device I could test it on. If that is so then I can also do it myself the way you described. Else some upload service like google docs or something should give you some upload space.

You build it with Android NDK. I used Android NDK r7.

I didn’t use Eclipse to build. The Android NDK comes with a bunch of scripts. ndk-build is one of them. You just need to write up some Android.mk files and an Application.mk and build it within an Android project (which you can create using the Android SDK).

I’ll look at hosting these files for people to download :slight_smile: