com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: - Error

六月ゝ 毕业季﹏ 提交于 2019-12-18 09:38:32

问题


I am trying to develop an application in libGDX for iOS.

In my Java class I have written this line

private Texture texture = new Texture(Gdx.files.internal("data/folder_name_1/folder_name_2/abcd.png"));

and my robovm.xml looks like this-

<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. But when I try to run it on an iOS device i.e. 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'.


回答1:


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.

Also when loading textures you don't need to use a FileHandler.. This would be enough:

texture = new Texture("image.png");

which would be the root (assets) folder of the android project




回答2:


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. that's all!



来源:https://stackoverflow.com/questions/25138314/com-badlogic-gdx-utils-gdxruntimeexception-couldnt-load-file-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!