Sorry if this is in the wrong section. If it is, can someone please put it in the right one. Anyway, when I try using libGDX and I put my resources in the android project, I get an error that says:
Couldn’t load file apple.png (that is one of the resources). ???
Can you please help me
Thanks
Ok, source at least? File loading is so basic that you must be doing something wrong in your code (and I thought you were learning LWJGL).
Resources go in the assets folder, and you have to make a linked folder in the desktop project with the assets folder in the android project, otherwise resources will have to be synced manually (copy+paste).
For loading from the assets folder you must use Gdx.files.internal (not sure exactly what local does but stick to internal), make sure you’re not using Gdx.files.absolute as that will require a full directory (e.g. C:/Users/User/EclipseWorkspace/…)
nOQt94fcoFo
You seem to be loading the textures correctly so I assume it must be a problem with your project setup.
Is “apple.png” in the Android “assets” folder AND in the desktop “assets” folder? (Did you link the folders? If you didn’t you should)
Did you hit refresh on the android project, and the desktop project if the assets folder isn’t linked?
Oh yeah, and this is definitely the wrong section. Why would a libgdx resources problem go under OpenGL Development? ???
I refreshed and it isn’t in both folders. The problem remains
Can you see the picture in eclipse, under the project?
Use the setup-ui to create your Eclipse projects. Here’s a video tutorial http://code.google.com/p/libgdx/wiki/ProjectSetupNew
In short: run the gdx-setup-ui.jar, fill in the values for project names etc. in the UI, hit generate, import the Eclipse projects into your workspace and all will be well.
Your Android project’s asset/ folder will contain the real assets, the desktop and other projects link to that folder.
I made a project using the setup jar. I then put all my stuff into the android assets. I imported the project into eclipse. I then copied the code from my former project into my new one. i could see the pictures (and music) in the assets folder in eclipse. It still doesn’t work.
Like I said, you need to link the assets in the android to the assets in the desktop…does the ui do that? Never used it.
Full error trace? Maybe you’re using OpenGLES 1 and your image’s dimensions aren’t a power of 2?
I set it to GL20. It still doesn’t work.
This is the stack trace on the console in eclipse:
(I couldn’t find the other part)
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: apple.png
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:111)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: apple.png
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:175)
at com.badlogic.gdx.graphics.Texture.create(Texture.java:159)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:122)
at com.me.mygdxgame.Munch.create(Munch.java:35)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:125)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:108)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: apple.png (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:127)
at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:566)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:215)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
... 8 more
I am so stupid!! (whacks hand on forehead) I forgot to put the /data in front of the paths!! :cranky:
Thanks for your help anyway. ;D
Please, try to debug the obvious before asking. You should have seen the data folder in the eclipse project structure, and we can’t see what’s on your computer.