[英]com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: - Error
I am trying to develop an application in libGDX for iOS.我正在尝试在 libGDX 中为 iOS 开发一个应用程序。
In my Java class I have written this line在我的 Java 类中,我写了这一行
private Texture texture = new Texture(Gdx.files.internal("data/folder_name_1/folder_name_2/abcd.png"));
and my robovm.xml looks like this-我的 robovm.xml 看起来像这样-
<iosInfoPList>Info.plist.xml</iosInfoPList>
<resources>
<resource>
<directory>../android/assets</directory>
<includes>
<include>**</include>
</includes>
<skipPngCrush>true</skipPngCrush>
</resource>
<resource>
<directory>data</directory>
</resource>
</resources>
When I try to run the code on iOS simulator it runs fine.当我尝试在 iOS 模拟器上运行代码时,它运行良好。 But when I try to run it on an iOS device ie iPhone.但是当我尝试在 iOS 设备(即 iPhone)上运行它时。 It generates an error which looks like this-它会产生一个错误,看起来像这样 -
com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/folder_name_1/folder_name_2/abcd.png
Can someone help me with this ?有人可以帮我弄这个吗 ?
Note:- in my iOS project in the data folder, there is another 'data' folder in which there is another folder named 'folder_name_1', then inside it I have 'folder_name_2' folder and inside it I have my png file 'abcd.png'.注意:- 在我的 iOS 项目的数据文件夹中,有另一个“数据”文件夹,其中有另一个名为“folder_name_1”的文件夹,然后在其中我有“folder_name_2”文件夹,在其中我有我的 png 文件“abcd”。 png'。
You've got the error right in front of you...你的错误就在你面前......
<directory>../android/assets</directory>
the resource you are looking for is NOT in the "data" folder.您要查找的资源不在“数据”文件夹中。 It's in the "Assets" which is in the android project.它位于android项目中的“资产”中。
Also when loading textures you don't need to use a FileHandler.. This would be enough:此外,在加载纹理时,您不需要使用 FileHandler .. 这就足够了:
texture = new Texture("image.png");
which would be the root (assets) folder of the android project这将是 android 项目的根(资产)文件夹
I also suffer this problem,I seemingly solve it.我也遇到这个问题,貌似解决了。 That is:I get GDX project from excuting gdx-setup.jar,and obtain all so files in lib directroy.即:执行gdx-setup.jar得到GDX工程,在lib目录下获取所有so文件。 that's all!就这样!
I had the same issue.我遇到过同样的问题。 I have cleaned and rebuild the project, and after that it works fine for me.我已经清理并重建了该项目,之后它对我来说效果很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.