libgdx -- Gdx.files.internal(); --> File Not Found

audio, desktop, eclipse, java, libgdx

Solution

Try "cleaning" your project by going to Project-> Clean. Also try "refreshing" your libGDX desktop folder by right clicking and using Gradle-> Refresh All

libGDX uses linked folders. You only need to copy the file to one of your asset folders (do this in eclipse, not in file explorer.)

Problem

I've been having trouble using the Gdx.files.internal() from libgdx; it seems that every time I run it as a desktop application i get this main error: Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: \data\sounds\music\mainmusic.mp3 (Internal) at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136) at com.badlogic.gdx.backends.lwjgl.audio.Mp3$Music.(Mp3.java:42) ... 10 more I've read 5 separate threads in the matter, one of which seemed like was the most likely problem so I've tried... - creating a data folder under assets - refreshing the eclipse explorer - Project > clean - manually creating an assets/data folder in bin (in core) - triple checking file paths - restarting the IDE my complete path is in /Flipcrew Legends-desktop/assets/data/sounds/music/mainmusic.mp3 public class SplashScreen implements Screen{ ``` final FlipcrewLegends game; Texture splashTexture; Sprite splashSprite; SpriteBatch batch; TweenManager manager; Music introMusic; public SplashScreen(FlipcrewLegends game) { this.game = game; introMusic = Gdx.audio.newMusic(Gdx.files.internal("data/sounds/music/mainmusic.mp3")); introMusic.setLooping(true); } ``` This However... seems to be working.. ``` @Override public void show() { splashTexture = new Texture("data/images/main/splash.png"); splashTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); splashSprite = new Sprite(splashTexture); splashSprite.setColor(1, 1, 1, 0); } ``` path: /Flipcrew Legends-desktop/assets/data/images/main/splash.png // Rest of class is omitted b/c it doesn't seem necessary (I can add it if requested) //unfortunately, Gdx.audio.newMusic doesnt seem to have a direct string path method so I couldn't try that out Additional Info: -> I've tried copying the assets folder in the desktop folder from core to no avail (deleted after) -> One thread said that libgdx usually takes the data from the android folder and then applies it to the desktop (unfortunately I started with only the desktop, no android) but I'm guessing libgdx has been nightly updated since the last date of that post, maybe an alternative has been added for that? edit: Just now after reverting assets/data/etc.... into assets/etc..... even the `new Texture(path);` is getting the same error - still doesn't work... retried methods above, will restart the computer after posting, might be a compiling issue. restarted computer, no difference

Original source