问题
I searched in a number of forums and it seems to be a common question. However i couldnt find a solution. I didnt do anything crazy so it seems stange that this happens.
@Override
protected Scene onCreateScene() {
Scene s = new Scene();
PhysicsWorld mWorld=new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH),true);
s.registerUpdateHandler(mWorld);
final Sprite eliSprite = new Sprite(400, 240, james_walking[3], getVertexBufferObjectManager());
eliSprite.setScale(0.5f);
s.attachChild(eliSprite);
s.setTouchAreaBindingOnActionDownEnabled(true);
return s;
}
I dont have much more to say because i dont know much about Andengine so a dummies explanation would be apreciated. After adding what you said the error goes out, however the PhysicsWorld still doesnt work. THe logcat says
02-27 17:07:51.153 2590-2639/com.company.m.appname D/dalvikvm﹕ No JNI_OnLoad found in /data/data/com.company.m.appname/lib/libandenginephysicsbox2dextension.so 0x41cdce70, skipping init
回答1:
Probably native libraries (.so files from lib dir) is missing from your APK. Check your project settings / build configuration.
If you're using android studio, you have to modify the sourceSet of andEngine and andEnginePhysicsBox2DExtension in build.gradle.
You have a folder in that projects where there are so files, you need to include the native libraries from there.
Check my answer here: jniLibs are not extended in gradle
Update based on your comments:
Add this to andEngine, andEnginePhysicsBox2d and your game build.gradle:
sourceSets {
main {
jni.srcDirs = []
jniLibs.srcDir 'libs'
}
}
Also add this to the defaultConfig section, for andEngine:
ndk {
moduleName "andEngine"
}
and for andEnginePhysicsBox2d:
ndk {
moduleName "andEnginePhysicsBox2dExtension"
}
来源:https://stackoverflow.com/questions/28750746/exceptionininitializererror-physics-world