Android上的Libgdx无法检测GDX字体

Ram*_*Vel 5 fonts android intellij-idea libgdx

我试图使用libgdx渲染简单的文本BitmapFont:

 font = new BitmapFont();
 font.draw(batch, "Tap anywhere to begin!", 100, 100);
Run Code Online (Sandbox Code Playgroud)

它在桌面上工作正常,但android它给出了这个错误:

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)
Run Code Online (Sandbox Code Playgroud)

似乎无法加载字体文件

File not found: com/badlogic/gdx/utils/arial-15.fnt (Classpath)
Run Code Online (Sandbox Code Playgroud)

我使用的intelliJ Idea不是Eclipse IDE.我认为这是由于一些路径配置问题,但无法弄清楚是什么.有人可以帮我吗?

更新

我已经打开了使用创建的示例libgdx demo apk eclipse,它在gdx 文件夹中有这4个文件utils

  • 宋体,15.fnt
  • 宋体-15.png
  • JsonReader.rl
  • XmlReader.rl

而在我生成的apk中intelliJ,它只有2个文件

  • JsonReader.rl
  • XmlReader.rl

arial-15 不见了.

use*_*917 5

从主lib目录中删除gdx-sources.jar之后,一切正常.也许是IntelliJ IDEA的错误?


小智 1

gdx-sources.jar从主目录中删除libs,工作正常,但是当我们在使用 IntelliJ 时按 Ctrl+Q 时,我们需要文档。

所以,我没有删除,gdx-sources.jar但我将它移动到 下的一个新目录中Main,命名它sourcelibs,然后我转到project structure/Libraries/Mainlibs(或其他),在依赖项中我删除了源条目(它不再有任何意义)并按“加号”来附加文件或目录,我添加了新目录。现在有一个带有新目录的新源条目。

所以现在没有错误了(感谢user2206917),而且我们也有文档了!