Search code examples
libgdx

Why won't my libgdx generated project run?


I created a libgdx project for android desktop HTML and iOS with the libgdx gradle setup then i imported it in eclipse. I tried to run the desktop application with no changes and this is what eclipse outputs.

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.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 si.borenovic.igor.samplegame.SampleGameMain.create(SampleGameMain.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: badlogic.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

Solution

  • This is because libgdx doesn't find the image file "badlogic.jpg". To do this you shoud add a link in your desktop application from the assets folder in the Android app.

    In this link it is explained better how to do it:

    http://www.badlogicgames.com/wordpress/?p=1537