# How to save file in assets so it can be properly loaded in Android Studio?

I am following a guide on creating a replica of Flappy Bird. - http://www.kilobolt.com/day-6-adding-graphics---welcome-to-the-necropolis.html

The step I am having trouble is loading the texture from the assets directory. There are the author's instructions on how to do this.

And the code that he uses to actually load the texture

        texture = new Texture(Gdx.files.internal("data/texture.png"));


My file structure looks like this(I am using Android Studio 1.0 while the author is using eclipse)

I had to manually create the data directory inside the assets folder. However when I try to run the application, I get these exceptions

Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/texture.png


Does anyone know what the issue is? The texture.png is clearly inside the data directory of assets. I also made sure to clean the project right after copying the .png file into the data directory as the author mentioned.(so resources can be properly loaded). Is the issue just that were using two different IDES, so that different method calls have to be made?

• in visual studio you have to change the properties of the image to "copy to output dire: copy always" and "build action: android asset", is there something similar in android studio ? also by any chance is the "/" a problem ? maybe it needs a "\" ? – dimitris93 Jan 24 '15 at 9:26
• @Shiro It should be a forward slash. Windows accepts forward slashes for most paths since Windows 98, so don't think that's the actual issue . – Mario Jan 24 '15 at 10:00
• @Mario i thought that because in the error it says Couldn't load file: data/texture.png File not found: data\texture.png – dimitris93 Jan 24 '15 at 10:06
• @Shiro That's probably due to the path conversion happening behind the scenes, however it might actually be some odd bug in com.badlogic.gdx as well (like backslashes being introduced somewhere but then handled the wrong way). – Mario Jan 24 '15 at 10:08
• Just something for you to try: Does the error also happen if you call the file _texture.png, i.e. avoiding the \t sequence in the path? – Mario Jan 24 '15 at 10:08