com.badlogic.gdx.utils.GdxRuntimeException:无法加载文件: – 错误

我正在尝试在iOS的libGDX中开发一个应用程序。

在我的Java课程中,我写了这一行

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

我的robovm.xml看起来像这样 –

 Info.plist.xml   ../android/assets  **  true   data   

当我尝试在iOS模拟器上运行代码时运行正常。 但是当我尝试在iOS设备(即iPhone)上运行它时。 它产生的错误看起来像这样 –

 com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/folder_name_1/folder_name_2/abcd.png 

有人可以帮我弄这个吗 ?

注意: – 在我的数据文件夹中的iOS项目中,还有另一个’data’文件夹,其中有另一个名为’folder_name_1’的文件夹,然后在其中我有’folder_name_2’文件夹,在其中我有我的png文件’abcd。 PNG”。

你面前的错误就在你面前……

  ../android/assets 

您要查找的资源不在“data”文件夹中。 它位于android项目中的“Assets”中。

此外,在加载纹理时,您不需要使用FileHandler ..这就足够了:

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

这将是android项目的root(assets)文件夹

我也遇到了这个问题,我似乎解决了这个问题。 那就是:我从gdx-setup.jar中获取GDX项目,并获取lib directroy中的所有文件。 就这样!