GdxRuntimeException在Android:无法加载共享库“GDX”为目标加载、目标、GdxRuntimeException、Android

2023-09-12 10:03:27 作者:缘尽了′情淡了

我已经开发了Libgdx应用程序,并在我的三星Galaxy S3(4.1.2),它是伟大的工作进行了测试。我试图在银河大(4.1.2)测试,但失败了。在logcat中,我发现了以下内容:

 引起com.badlogic.gdx.utils.GdxRuntimeException无法加载共享库GDX的目标:Linux上,32位
 

这发生改变设备时,只所以任何想法是什么原因呢?!

完整logcat的:

  05-22 20:25:01.745:E / AndroidRuntime(12725):致命异常:主要
05-22 20:25:01.745:E / AndroidRuntime(12725):java.lang.ExceptionInInitializerError
05-22 20:25:01.745:E / AndroidRuntime(12725):在java.lang.Class.newInstanceImpl(本机方法)
05-22 20:25:01.745:E / AndroidRuntime(12725):在java.lang.Class.newInstance(Class.java:1319)
05-22 20:25:01.745:E / AndroidRuntime(12725):在android.app.Instrumentation.newActivity(Instrumentation.java:1068)
05-22 20:25:01.745:E / AndroidRuntime(12725):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
05-22 20:25:01.745:E / AndroidRuntime(12725):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
05-22 20:25:01.745:E / AndroidRuntime(12725):在android.app.ActivityThread.access $ 700(ActivityThread.java:140)
05-22 20:25:01.745:E / AndroidRuntime(12725):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1237)
05-22 20:25:01.745:E / AndroidRuntime(12725):在android.os.Handler.dispatchMessage(Handler.java:99)
05-22 20:25:01.745:E / AndroidRuntime(12725):在android.os.Looper.loop(Looper.java:137)
05-22 20:25:01.745:E / AndroidRuntime(12725):在android.app.ActivityThread.main(ActivityThread.java:4935)
05-22 20:25:01.745:E / AndroidRuntime(12725):在java.lang.reflect.Method.invokeNative(本机方法)
05-22 20:25:01.745:E / AndroidRuntime(12725):在java.lang.reflect.Method.invoke(Method.java:511)
05-22 20:25:01.745:E / AndroidRuntime(12725):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-22 20:25:01.745:E / AndroidRuntime(12725):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-22 20:25:01.745:E / AndroidRuntime(12725):在dalvik.system.NativeStart.main(本机方法)
05-22 20:25:01.745:E / AndroidRuntime(12725):com.badlogic.gdx.utils.GdxRuntimeException:产生的原因无法加载共享库GDX的目标:Linux上,32位
05-22 20:25:01.745:E / AndroidRuntime(12725):在com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:104)
05-22 20:25:01.745:E / AndroidRuntime(12725):在com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:34)
05-22 20:25:01.745:E / AndroidRuntime(12725):在com.badlogic.gdx.backends.android.AndroidApplication< clinit>(AndroidApplication.java:61)
05-22 20:25:01.745:E / AndroidRuntime(12725):15 ...更多
05-22 20:25:01.745:E / AndroidRuntime(12725):致:java.lang.UnsatisfiedLinkError中:无法加载GDX:findLibrary返回null
05-22 20:25:01.745:E / AndroidRuntime(12725):在java.lang.Runtime.loadLibrary(Runtime.java:365)
05-22 20:25:01.745:E / AndroidRuntime(12725):在java.lang.System.loadLibrary(System.java:535)
05-22 20:25:01.745:E / AndroidRuntime(12725):在com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:100)
05-22 20:25:01.745:E / AndroidRuntime(12725):17 ...更多
 

解决方案

我收到完全相同的错误,因为原来的职位,当我试图加载由libGDX生成到Android的Studio项目:

 > 造成com.badlogic.gdx.utils.GdxRuntimeException无法加载
>共享库GDX的目标:Linux上,32位
 
安卓手机解决手机发热问题,养成良好的习惯

在一些研究(特别是www.badlogicgames.com/forum/viewtopic.php?f=11&t=9097~~V),我发现这个优秀的教程由 evilEntity 的表现如何导入libGDX项目到Android的工作室:

http://imgur.com/a/IBFIV 。

我不能重复教程逐字因为它的文字和截图,但下面的步骤让我只在本教程中列出的修改将生成的项目:

请注意,我是在重复evilentity的答案在这里,因为它在不同的论坛上不同的网站,并有充足的评论在堆栈溢出表明它是不好的形式简单地发布链接到其他网站上的解决方案。

请也注意,我包括这个答案在这里,因为它是包含在omarsafwany的问题,这是关键点对我来说,而不是围绕他的问题的具体情况的错误消息。希望这是确定的。

导入项目: 选择包含所有三个生成项目顶层文件夹(共享,桌面,安卓) 选择从现有来源创建proejct 重命名三个库(库= LibGDX - 桌面,libs1 = LibDGX-的Andr​​oid,libs2 = LibDGX共享) 在接受剩余的默认值,然后单击完成 在所有这三个项目应该出现在项目资源管理器。 导出共享库 右键单击共享的模块,并选择打开模块设置 转到共享的模块,然后选择导出旁边libgdx共享库 转到Android的模块,并添加共享模块依赖(点击绿色+) 转到桌面模块,并添加共享模块依赖(点击绿色+) 编辑Android的运行配置 在加入-Android的现有名称结束重命名的android配置 在选择显示选择对话框,目标设备 添加桌面运行配置 点击绿色+,然后选择应用程序 在给它一些名字在上面,接下来点击......旁边的主类字段。在对话框中选择项目,并找到主类的桌面启动器。单击确定。 现在,我们需要改变工作目录。请点击...并从文件夹视图中选择资产的android启动文件夹中。没有它的桌面启动器将无法找到所需的图像和其他的东西来运行。 最后要做的事情就是选择类路径中。选择桌面模块。单击确定。

详细信息:

Android的工作室版本:AI-130.737825(2013年7月11日) JRE:1.7.0_25 libGDX:从2013年8月15日每日构建 在Android设备:谷歌Nexus 7 将生成的项目:GDX-设置-ui.jar(从 http://libgdx.badlogicgames.com下载/ nightlies / )

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

The complete 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

解决方案

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"

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.

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:

Please note that I am repeating evilentity's answer here because it's in a different forum on a different site, and there's ample comments in Stack overflow indicating that it's bad form to simply post links to solutions on other sites.

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.

Import project: Select top folder containing all three generated projects (shared, desktop, android) Select "Create proejct from existing sources" Rename the three libraries (libs = LibGDX-Desktop, libs1 = LibDGX-Android, libs2 = LibDGX-Shared) Accept remaining defaults and click "finish" All three projects should appear in your project explorer. Export shared library Right-click shared module and select "Open Module Settings" Go to shared module and select "export" next to libgdx shared library Go to android module and add shared module as dependency (by clicking on green +) Go to desktop module and add shared module as dependency (by clicking on green +) Edit Android Run Configuration rename android configuration by adding "-android" to end of existing name select "Show chooser dialog" in "target device" Add Desktop Run Configuration Click on green + and select "application" Give it some name at the top, next click on ... next to 'Main class' field. In the dialog select project and find main class of desktop starter. Click ok. Now we need to change working directory. Click on ... and from folder view select assets folder of android starter. Without it desktop starter wont be able to find required images and other things to run. Last things to do is to select classpath. Select desktop module. Click ok.

Details:

Android Studio Version: AI-130.737825 (July 11, 2013) JRE: 1.7.0_25 libGDX: Nightly build from 8/15/2013 Android Device: Google Nexus 7 Projects generated by: gdx-setup-ui.jar (downloaded from http://libgdx.badlogicgames.com/nightlies/)