ExceptionInInitializerError 物理世界 [英] ExceptionInInitializerError Physics World

查看:25
本文介绍了ExceptionInInitializerError 物理世界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在许多论坛中搜索过,这似乎是一个常见问题.但是我找不到解决方案.我没有做任何疯狂的事情,所以发生这种情况似乎很奇怪.

@Override受保护的场景 onCreateScene() {场景 s = 新场景();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);返回 s;}

我没有更多要说的,因为我对 Andengine 不太了解,所以我会感谢一个傻瓜的解释.添加您所说的内容后,错误消失了,但是 PhysicsWorld 仍然无法正常工作.logcat 说

02-27 17:07:51.153 2590-2639/com.company.m.appname D/dalvikvm:在/data/data/com.company.m.appname/lib/libandenginephysicsbox2dextension中没有找到JNI_OnLoad.所以 0x41cdce70,跳过初始化

解决方案

可能是您的 APK 中缺少本机库(来自 lib 目录的 .so 文件).检查您的项目设置/构建配置.

如果你使用的是android studio,你需要修改build.gradle中andEngine和andEnginePhysicsBox2DExtension的sourceSet.

您在该项目中有一个文件夹,其中包含 so 文件,您需要从那里包含本机库.

在这里查看我的答案:jniLibs 未在 gradle 中扩展

根据您的评论更新:

将此添加到 andEngine、andEnginePhysicsBox2d 和您的游戏 build.gradle:

sourceSets {主要的 {jni.srcDirs = []jniLibs.srcDir '库'}}

还要将此添加到 defaultConfig 部分,用于 andEngine:

ndk {模块名称andEngine"}

对于 andEnginePhysicsBox2d:

ndk {moduleName "andEnginePhysicsBox2dExtension"}

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆