Libgdx project Exception in thread “LWJGL Application”. Couldn't load file. Error log inside

こ雲淡風輕ζ 提交于 2019-12-20 13:01:09

问题


I am a newbie in libgdx and just got it setup in android studio. Now I am getting this error when I press run for the first time.

/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java 
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic1.jpg
    at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
    at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
    at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
    at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
    at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
    at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
    at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:88)
    at com.TigerBudda.ZombieBird.ZBGame.create(ZBGame.java:16)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: badlogic1.jpg (Internal)
    at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
    at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:220)
    at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
    ... 9 more

回答1:


Are you run Desktop Application? Make sure you link your desktop assets to android assets folder?

On Eclipse : New libgdx setup receive file not found

Edited:

On Android Studio

Choose Edit Configuration.. => "Working directory" => Change folder to android/assets




回答2:


static{
    System.out.println(Gdx.files.getLocalStoragePath());
}

It displayed the path to the project root folder outside the android/desktop specific modules. Copied to files to a path relative to the root folder of project and it worked.

Project Project/core Project/android Project/desktop Project/html Project/android/assets/data/img.png What worked: Project/data/img.png




回答3:


In my case installing nvidia-375 driver solved the issue.

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-375

reboot. And then ta-da! It's working.



来源:https://stackoverflow.com/questions/24879812/libgdx-project-exception-in-thread-lwjgl-application-couldnt-load-file-erro

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