3

I've got Gradle projects and 2 IDE's: NetBeans and IntelliJ. NetBeans works perfectly with this project, no errors found. But IntelliJ in the same project throws exception:

[Assets] error: com.badlogic.gdx.utils.GdxRuntimeException: File not found: ./images/enemy.atlas (Internal)

Here is Java class:

public class Assets {           
    public static AssetManager assetManager;           
    public Assets() {
        assetManager = new AssetManager();
        try {
            assetManager.load("./images/enemy.atlas", TextureAtlas.class);
            assetManager.load("./images/buttons.atlas", TextureAtlas.class);
            assetManager.load("./fonts/000.fnt", BitmapFont.class);
            assetManager.load("./fonts/111.fnt", BitmapFont.class);
            assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
            assetManager.load("./world/level1/map.tmx", TiledMap.class);
            assetManager.finishLoading();
        } catch (GdxRuntimeException e) { if (Variables.isDebug) System.err.println("\n[Assets] error: " + e + "\n"); }
     } 
}

It is simple, right? So, I've looked through *.gradle files and noticed that gradle knows where to search for my assets:

project.ext.assetsDir = new File("../android/assets");

I've remade project especially for IDEA (using gdx-setup.jar), but same problem arises. I'm confused and asking for advise!

P.S. AssetManager is a class of LibGDX 1.1.0 library.

Opal
  • 81,889
  • 28
  • 189
  • 210
Dima Gram
  • 31
  • 1
  • 4
  • Were you able to compile and run the simple "Hello, World!" app that `gdx-setup.jar` creates before adding your own code? – Code-Apprentice Sep 15 '14 at 20:58
  • Possible duplicate of ["File not found" when running new LibGDX project](http://stackoverflow.com/questions/22822767/file-not-found-when-running-new-libgdx-project) – Code-Apprentice Dec 08 '16 at 17:14

4 Answers4

0

Have you tried ommiting the ./ at the beginning of the path? See: https://github.com/libgdx/libgdx/wiki/Managing-your-assets#loading-assets

./ usually references the current directory, but I don't know how libgdx handles it. I can't post this as a comment somehow.

DenisG
  • 59
  • 1
  • 5
0

I had similar problem. After 3 hours of being angry i realized that path is case sensitive. Example for tile map:

Android assets file structure: assets/Maps/Desert.tmx

//Work as desktop luncher but not on android
TiledMap tiledMap = new TmxMapLoader().load("maps\\Desert.tmx"); 

//Works on android and dektop
TiledMap tiledMap = new TmxMapLoader().load("Maps\\Desert.tmx");

Second thing which I noticed is that path shouldn't start with

./  
../
.\\
..\\

//Enough
"Maps\\Desert.tmx"

//Too much
".\\Maps\\Desert.tmx"
LukaszTaraszka
  • 801
  • 1
  • 10
  • 26
0

One of the possible way outs for IDEA is to set the Working directory for the Desktop run configuration to your android/assets/ folder.

tilex
  • 1,744
  • 1
  • 17
  • 32
-1

You need to tell the "desktop module" to look for assets in the "android module." I forget the exact steps to do this...

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268