的ExceptionInInitializerError物理世界 [英] ExceptionInInitializerError Physics World
问题描述
我搜索在一些论坛,这似乎是一个常见的问题。但我不能找到一个解决方案。如此看来STANGE,出现这种情况我没有做任何疯狂。
@覆盖
保护场景onCreateScene(){
场景S =新场景();
PhysicsWorld mWorld =新PhysicsWorld(新Vector2(0,SensorManager.GRAVITY_EARTH),TRUE);
s.registerUpdateHandler(mWorld);
最终的Sprite eliSprite =新的Sprite(400,240,james_walking [3],getVertexBufferObjectManager());
eliSprite.setScale(0.5F);
s.attachChild(eliSprite);
s.setTouchAreaBindingOnActionDownEnabled(真正的);
返回S;
}
我没有多说,因为我不知道很多关于Andengine这样一个傻瓜的解释将是preciated。 将你所说的话后,错误熄灭,但是PhysicsWorld仍然不起作用。在logcat的说
02-27 17:07:51.153 2590至2639年/ com.company.m.appname D / dalvikvm:没有JNI_OnLoad在/data/data/com.company.m发现。应用程序的名字/ lib目录/ libandenginephysicsbox2dextension.so 0x41cdce70,跳过INIT
大概是本地库(.so从lib目录文件)从你的APK失踪。检查项目设置/生成配置。
如果您使用的是Android的工作室,你必须修改andEngine和andEnginePhysicsBox2DExtension的sourceSet在build.gradle。
您必须在项目中有那么文件的文件夹,你需要从那里包括本地库。
检查我的答案在这里:没有延续 jniLibs在摇篮
根据您的意见更新:
这添加到andEngine,andEnginePhysicsBox2d和你的游戏build.gradle:
sourceSets {
主要 {
jni.srcDirs = []
jniLibs.srcDir'库'
}
}
另外补充这对defaultConfig部分中,andEngine:
NDK {
MODULENAMEandEngine
}
和andEnginePhysicsBox2d:
NDK {
MODULENAMEandEnginePhysicsBox2dExtension
}
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
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"
}
这篇关于的ExceptionInInitializerError物理世界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!