实施加速度计(Andengine)时出现的问题

发布于 2024-11-26 13:12:12 字数 2932 浏览 0 评论 0原文

我正在尝试使用 Andengine 在我的游戏中实现 Accelerometer 并且我还添加 andenginephysicalsbox2dextension.jar

private PhysicsWorld mPhysicsWorld;

//--OnLoadScene()

this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);

当我实现这一行时,我收到错误并且无法运行。

如何修复这个错误?

Logcat 错误:

07-27 13:57:21.125: ERROR/AndroidRuntime(1006): FATAL EXCEPTION: main
07-27 13:57:21.125: ERROR/AndroidRuntime(1006): java.lang.ExceptionInInitializerError
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at Org.Demo.PixelPerfectTest.onLoadScene(PixelPerfectTest.java:223)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at org.anddev.andengine.ui.activity.BaseGameActivity.doResume(BaseGameActivity.java:158)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at org.anddev.andengine.ui.activity.BaseGameActivity.onWindowFocusChanged(BaseGameActivity.java:82)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onWindowFocusChanged(PhoneWindow.java:2152)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.view.View.dispatchWindowFocusChanged(View.java:4691)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:752)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.view.ViewRoot.handleMessage(ViewRoot.java:2102)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.os.Looper.loop(Looper.java:132)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.app.ActivityThread.main(ActivityThread.java:4025)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at java.lang.reflect.Method.invokeNative(Native Method)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at java.lang.reflect.Method.invoke(Method.java:491)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at dalvik.system.NativeStart.main(Native Method)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load andenginephysicsbox2dextension: findLibrary returned null
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at java.lang.Runtime.loadLibrary(Runtime.java:425)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at java.lang.System.loadLibrary(System.java:554)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at org.anddev.andengine.extension.physics.box2d.PhysicsWorld.<clinit>(PhysicsWorld.java:30)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     ... 15 more

I am trying to implement Accelerometer in my game using Andengine and i also add andenginephysicsbox2dextension.jar

private PhysicsWorld mPhysicsWorld;

//--OnLoadScene()

this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);

When i implement this line i got error and not able to run.

How to fix this error?

Logcat Errors:

07-27 13:57:21.125: ERROR/AndroidRuntime(1006): FATAL EXCEPTION: main
07-27 13:57:21.125: ERROR/AndroidRuntime(1006): java.lang.ExceptionInInitializerError
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at Org.Demo.PixelPerfectTest.onLoadScene(PixelPerfectTest.java:223)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at org.anddev.andengine.ui.activity.BaseGameActivity.doResume(BaseGameActivity.java:158)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at org.anddev.andengine.ui.activity.BaseGameActivity.onWindowFocusChanged(BaseGameActivity.java:82)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onWindowFocusChanged(PhoneWindow.java:2152)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.view.View.dispatchWindowFocusChanged(View.java:4691)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:752)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.view.ViewRoot.handleMessage(ViewRoot.java:2102)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.os.Looper.loop(Looper.java:132)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at android.app.ActivityThread.main(ActivityThread.java:4025)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at java.lang.reflect.Method.invokeNative(Native Method)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at java.lang.reflect.Method.invoke(Method.java:491)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at dalvik.system.NativeStart.main(Native Method)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load andenginephysicsbox2dextension: findLibrary returned null
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at java.lang.Runtime.loadLibrary(Runtime.java:425)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at java.lang.System.loadLibrary(System.java:554)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     at org.anddev.andengine.extension.physics.box2d.PhysicsWorld.<clinit>(PhysicsWorld.java:30)
07-27 13:57:21.125: ERROR/AndroidRuntime(1006):     ... 15 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

携君以终年 2024-12-03 13:12:12

您必须将 .so 文件包含在库中,并通过项目属性添加 .jar 文件。
两个.so文件有两个版本(arneabu和armeabi-v7a)......我不知道
这是最新的。将它们放入库中并确保刷新构建路径。

然后,如果您还没有这样做,请确保包含相关的 .jar 文件
在 Eclipse 中调出“项目属性”。然后,在不加载 Eclipse 的情况下(我必须
关闭这个浏览器以避免这台 POS 笔记本电脑陷入过多的故障),我 99% 确定
在“构建路径”下,您将看到“添加外部 JAR”的选项。选择那个,然后
添加必要的 jar 文件。

显然,根据我读过的线程,忘记 .so 库有点
常见错误(我也犯过一个!)。

现在,如果您的应用程序是动态壁纸,则可能会出现任何 AndEngine 物理问题。
我读过很多关于人们遇到问题、寻找错误修复的帖子,
等等。

我现在在 AndEngine 论坛上有一个关于这个问题的悬而未决的问题。我
在我的物理学中根本无法让任何触摸事件或加速计工作
和基于物理的(物理/化学:Buckyballs (buckminsterfullerenes),以及物理代码
AndEngine)LWP 应用程序。我基本上遇到了一堵砖墙
在(并且如果)我收到最新更新的回复之前,继续前进是没有意义的
我添加了...

希望这有帮助...

稍后,
   --吉姆

You have to include the .so files in libs AND add the .jar files via Project Properties.
There are two versions of the two .so files (arneabu and armeabi-v7a) ... I don't know
which is more current. Put them in libs and make sure you refresh your build path.

Then, if you haven't already done so, make sure you include the relevant .jar files by
pulling up Project Properties in Eclipse. Then, without loading Eclipse (I'd have to
kill this browser to avoid bogging this POS laptop down too much), I'm 99% sure
it's under Build Path, you'll see an option to "Add External JARs". Select that, and
add the necessary jar files.

Apparently, based on a thread I read, forgetting the .so libs is a somewhat
common mistake (one I made, too!).

Now, if your app is a live wallpaper, expect problems with any AndEngine physics.
I've read a LOT of posts about people having problems, looking for a bug fix,
and so on.

I have an open question in the AndEngine forums now about that very issue. I
can't get any touch events or the accelerometer to work AT ALL in my physics
and physics-based (physics/chemistry: Buckyballs (buckminsterfullerenes), and physics code for
AndEngine) LWP app. I've basically run into a brick wall that makes it
pointless to move forward until (and IF) I get a response to the latest update
I added....

Hope this helps....

Later,
   --jim

清眉祭 2024-12-03 13:12:12

请注意这一行:

07-27 13:57:21.125: ERROR/AndroidRuntime(1006): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load andenginephysicsbox2dextension: findLibrary returned null

验证您的构建路径设置,也许您忽略了所需的库/扩展?根据您提供的信息,并考虑到我没有使用过该库。也许您需要将Physics Box2D 扩展添加到构建路径中。

问候。

Note this line:

07-27 13:57:21.125: ERROR/AndroidRuntime(1006): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load andenginephysicsbox2dextension: findLibrary returned null

Verify your Build Path settings, maybe you're ignoring a required library/extensions? By the information you give, and considering I haven't used that library. Maybe you need to add the Physics Box2D Extension to the Build Path.

Regards.

孤蝉 2024-12-03 13:12:12

GT布鲁尔。
只需在物理盒2d项目中构建本机库即可。然后 cp -r ./libs 从物理项目到动态壁纸项目。刷新,project->clean 然后构建。中提琴!

GTBrewer.
Simply build the native libs in the physicsbox2d project. then cp -r ./libs from the physics project to the live wallpaper project. refresh, project->clean then build. viola!

夜深人未静 2024-12-03 13:12:12

由于您的项目忽略 .so 文件。
您可以在这里关注我的答案 https://stackoverflow.com/a/34068202/2026280

或者

它非常简单。按照以下简单步骤操作

1)主应用的 libs 文件夹中创建一个名为“lib”的新文件夹。

2)复制andEnginePhysicsBox2DExtension/libs文件夹中的所有文件夹 ie.armabi 、armabi-v7a 等,并粘贴到之前创建的“lib”中> 主应用中的文件夹。

3) 现在将"lib"文件夹压缩为"lib.zip"并将其重命名为"lib.jar"。
这会将 zip 扩展名更改为 jar

4) 最后在 Build.gradle 文件中的 dependency{} 下添加一行 -- compile files('lib.jar')强>主应用程序。

5) 清理并构建项目。

As your project is ignoring .so files.
you can follow my answer here https://stackoverflow.com/a/34068202/2026280

or

Its very simple. Follow this simple steps

1) Create a new folder called "lib" inside the libs folder of the main app.

2) Copy all the folders ie.armabi , armabi-v7a etc from andEnginePhysicsBox2DExtension/libs folder, and paste in in the previously created "lib" folder in main app.

3) Now compress the "lib" folder as "lib.zip" and rename it to "lib.jar".
this changes the zip extension to jar.

4) Finally add a line -- compile files('lib.jar') under dependencies{} in Build.gradle file of your main app.

5) Clean and build the project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文