GdxRuntimeException on Android: couldn#39;t load shared library #39;gdx#39; for target(Android 上的 GdxRuntimeException:无法为目标加载共享库“gdx)
问题描述
我开发了一个 Libgdx 应用程序并在我的三星 Galaxy S3(4.1.2) 上对其进行了测试,它运行良好.我试图在 Galaxy Grand(4.1.2) 上对其进行测试,但失败了.在logcat中,我发现了以下内容:
I've developed a Libgdx application and tested it on my Samsung Galaxy S3(4.1.2) where it is working great. I tried to test it on a Galaxy Grand(4.1.2) but it failed. In the logcat, I found the following:
caused by com.badlogic.gdx.utils.GdxRuntimeException couldn't load shared library 'gdx' for target: Linux, 32-bit
这只是在更换设备时发生的,所以知道是什么原因吗?!
This happened when changing the device only so any idea what is the cause?!
完整的logcat:
05-22 20:25:01.745: E/AndroidRuntime(12725): FATAL EXCEPTION: main
05-22 20:25:01.745: E/AndroidRuntime(12725): java.lang.ExceptionInInitializerError
05-22 20:25:01.745: E/AndroidRuntime(12725): at java.lang.Class.newInstanceImpl(Native Method)
05-22 20:25:01.745: E/AndroidRuntime(12725): at java.lang.Class.newInstance(Class.java:1319)
05-22 20:25:01.745: E/AndroidRuntime(12725): at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
05-22 20:25:01.745: E/AndroidRuntime(12725): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
05-22 20:25:01.745: E/AndroidRuntime(12725): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
05-22 20:25:01.745: E/AndroidRuntime(12725): at android.app.ActivityThread.access$700(ActivityThread.java:140)
05-22 20:25:01.745: E/AndroidRuntime(12725): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
05-22 20:25:01.745: E/AndroidRuntime(12725): at android.os.Handler.dispatchMessage(Handler.java:99)
05-22 20:25:01.745: E/AndroidRuntime(12725): at android.os.Looper.loop(Looper.java:137)
05-22 20:25:01.745: E/AndroidRuntime(12725): at android.app.ActivityThread.main(ActivityThread.java:4935)
05-22 20:25:01.745: E/AndroidRuntime(12725): at java.lang.reflect.Method.invokeNative(Native Method)
05-22 20:25:01.745: E/AndroidRuntime(12725): at java.lang.reflect.Method.invoke(Method.java:511)
05-22 20:25:01.745: E/AndroidRuntime(12725): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-22 20:25:01.745: E/AndroidRuntime(12725): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-22 20:25:01.745: E/AndroidRuntime(12725): at dalvik.system.NativeStart.main(Native Method)
05-22 20:25:01.745: E/AndroidRuntime(12725): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx' for target: Linux, 32-bit
05-22 20:25:01.745: E/AndroidRuntime(12725): at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:104)
05-22 20:25:01.745: E/AndroidRuntime(12725): at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:34)
05-22 20:25:01.745: E/AndroidRuntime(12725): at com.badlogic.gdx.backends.android.AndroidApplication.<clinit>(AndroidApplication.java:61)
05-22 20:25:01.745: E/AndroidRuntime(12725): ... 15 more
05-22 20:25:01.745: E/AndroidRuntime(12725): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load gdx: findLibrary returned null
05-22 20:25:01.745: E/AndroidRuntime(12725): at java.lang.Runtime.loadLibrary(Runtime.java:365)
05-22 20:25:01.745: E/AndroidRuntime(12725): at java.lang.System.loadLibrary(System.java:535)
05-22 20:25:01.745: E/AndroidRuntime(12725): at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:100)
05-22 20:25:01.745: E/AndroidRuntime(12725): ... 17 more
推荐答案
当我尝试将 libGDX 生成的项目加载到 Android Studio 中时,我收到了与原帖完全相同的错误:
I received the exact same error as the original post when I tried to load projects generated by libGDX into Android Studio:
> "caused by com.badlogic.gdx.utils.GdxRuntimeException couldn't load
> shared library 'gdx' for target: Linux, 32-bit"
经过一番研究(特别是 www.badlogicgames.com/forum/viewtopic.php?f=11&t=9097),我发现 evilEntity 的这篇优秀教程展示了如何导入libGDX 项目进入 Android Studio:
After a bit of research (specifically www.badlogicgames.com/forum/viewtopic.php?f=11&t=9097), I found this excellent tutorial by evilEntity that showed how to import libGDX projects into Android Studio:
http://imgur.com/a/IBFIV.
http://imgur.com/a/IBFIV.
我不能逐字重复教程,因为它既是文本又是屏幕截图,但是按照这些步骤,我可以导入生成的项目,只需要教程中列出的修改:
I can't repeat the tutorial verbatim as it's both text and screenshots, but following the steps allowed me to import the generated projects with only the modifications listed in the tutorial:
请注意,我在这里重复 evilentity 的回答,因为它在不同站点的不同论坛中,并且 Stack overflow 中有大量评论表明在其他站点上简单地发布解决方案的链接是不好的形式.强>
还请注意,我在此处包含此答案,因为 omarsafwany 的问题中包含的错误消息对我来说是关键点,而不是围绕他的问题的具体情况.希望没关系.
Please also note that I am including this answer here as it was the error message contained in omarsafwany's question that was the key point for me, rather than the specific circumstances around his issue. Hopefully that's OK.
- 导入项目:
- 选择包含所有三个生成项目(共享、桌面、android)的顶级文件夹
- 选择从现有来源创建项目"
- 重命名三个库(libs = LibGDX-Desktop、libs1 = LibDGX-Android、libs2 = LibDGX-Shared)
- 接受剩余的默认设置并点击完成"
- 所有三个项目都应显示在您的项目资源管理器中.
- 右键单击共享模块并选择打开模块设置"
- 转到共享模块并选择 libgdx 共享库旁边的导出"
- 转到 android 模块并添加共享模块作为依赖项(通过单击绿色 +)
- 转到桌面模块并将共享模块添加为依赖项(通过单击绿色+)
- 通过在现有名称末尾添加-android"来重命名 android 配置
- 在目标设备"中选择显示选择器对话框"
- 点击绿色+并选择应用"
- 在顶部给它起个名字,然后点击主类"字段旁边的....在对话框中选择项目并找到桌面启动器的主类.点击确定.
- 现在我们需要更改工作目录.点击 ... 并从文件夹视图中选择 android starter 的 assets 文件夹.没有它,桌面启动器将无法找到运行所需的图像和其他内容.
- 最后要做的是选择类路径.选择桌面模块.点击确定.
详情:
- Android Studio 版本:AI-130.737825(2013 年 7 月 11 日)
- JRE:1.7.0_25
- libGDX:从 2013 年 8 月 15 日开始每晚构建
- Android 设备:Google Nexus 7
- 生成的项目:gdx-setup-ui.jar(从 http://libgdx.badlogicgames.com 下载/nightlies/)
这篇关于Android 上的 GdxRuntimeException:无法为目标加载共享库“gdx"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android 上的 GdxRuntimeException:无法为目标加载共享库
基础教程推荐
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01