Tuesday, February 28, 2017

libgdx - Why can't I read .ttf file when running Android configuration?


When running or debugging my game on Android device, I get this error in the logcat:



com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: data/fonts/myFont.ttf (Internal)



Which is created by this code line:


FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fontFile);

where fontFile is defined like this:


FileHandle fontFile = Gdx.files.internal("data/fonts/myFont.ttf");


This doesn't happen when I run the desktop configuration.


I know that for desktop configuration you have to define the working directory of your project, but I don't see such option in android configuration and it also makes no sense, so I don't think it's a "working directory"-related problem.


Obviously, the file is in the correct path.


Also note that everything worked fine in my previous project. I created this new project by creating a new blank prj using libgdx-setup and then copying all the classes and packages from the older project. So maybe it's a problem related to some Gradle file?




No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...