Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Libgdx on android not able to detect GDX fonts

I am trying to render simple text using the libgdx BitmapFont:

 font = new BitmapFont();
 font.draw(batch, "Tap anywhere to begin!", 100, 100);

It works fine in the desktop,But android it gives this error:

07-30 08:12:35.518: ERROR/AndroidRuntime(817): FATAL EXCEPTION: GLThread 82
        com.badlogic.gdx.utils.GdxRuntimeException: File not found: com/badlogic/gdx/utils/arial-15.fnt (Classpath)
        at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:132)
        at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:77)
        at com.badlogic.gdx.graphics.g2d.BitmapFont$BitmapFontData.<init>(BitmapFont.java:715)
        at com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:114)
        at com.badlogic.gdx.graphics.g2d.BitmapFont.<init>(BitmapFont.java:73)
        at com.mangokidzee.amphibian.Activity1.create(Activity1.java:23)
        at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:322)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

Seems it is unable to load the font file

File not found: com/badlogic/gdx/utils/arial-15.fnt (Classpath)

I am using intelliJ Idea not the Eclipse IDE. I think this is due to some path configuration issue but not able to figure out what. Can someone help me out?

Update

I have opened sample libgdx demo apk created using eclipse, it has these 4 files in the gdx utils folder

  • arial-15.fnt
  • arial-15.png
  • JsonReader.rl
  • XmlReader.rl

whereas in my apk generated using intelliJ, it has only 2 files

  • JsonReader.rl
  • XmlReader.rl

arial-15 is missing.

like image 899
RameshVel Avatar asked Jul 30 '13 08:07

RameshVel


2 Answers

After I removed the gdx-sources.jar from main lib dir,every thing works fine. Maybe a bug of IntelliJ IDEA?

like image 125
user2206917 Avatar answered Oct 26 '22 23:10

user2206917


Link the assets between Android module and Main module:

Create a directory named data in the main module, and make a sym-link from the assets directory in the Android module.

Here's the reference.

like image 40
Sajal Dutta Avatar answered Oct 26 '22 22:10

Sajal Dutta