简体   繁体   中英

Libgdx app can't run on android emulator

I've been trying to figure this out for couple days. I've tried to run the app on android emulator on eclipse and when I clicked on my app it gives me an error "unfortunately, app has stopped" The following is the Logcat.

03-21 19:01:19.145: I/AndroidGraphics(863): Managed buffers/app: { }
03-21 19:01:19.585: W/dalvikvm(863): threadid=11: thread exiting with uncaught exception (group=0x40a71930)
03-21 19:01:19.715: E/AndroidRuntime(863): FATAL EXCEPTION: GLThread 87
03-21 19:01:19.715: E/AndroidRuntime(863): com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: data/texture.png
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.graphics.Texture.load(Texture.java:142)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:133)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:112)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:104)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.AukaD.myHelpers.AssetLoader.load(AssetLoader.java:33)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.AukaD.FlyBird.MyGame.create(MyGame.java:10)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:334)
03-21 19:01:19.715: E/AndroidRuntime(863):  at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
03-21 19:01:19.715: E/AndroidRuntime(863):  at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
03-21 19:01:19.715: E/AndroidRuntime(863): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: data/texture.png (Internal)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:74)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.files.FileHandle.length(FileHandle.java:563)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.backends.android.AndroidFileHandle.length(AndroidFileHandle.java:162)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:218)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
03-21 19:01:19.715: E/AndroidRuntime(863):  ... 10 more
03-21 19:01:19.715: E/AndroidRuntime(863): Caused by: java.io.FileNotFoundException: data/texture.png
03-21 19:01:19.715: E/AndroidRuntime(863):  at android.content.res.AssetManager.openAsset(Native Method)
03-21 19:01:19.715: E/AndroidRuntime(863):  at android.content.res.AssetManager.open(AssetManager.java:315)
03-21 19:01:19.715: E/AndroidRuntime(863):  at android.content.res.AssetManager.open(AssetManager.java:289)
03-21 19:01:19.715: E/AndroidRuntime(863):  at com.badlogic.gdx.backends.android.AndroidFileHandle.read(AndroidFileHandle.java:72)
03-21 19:01:19.715: E/AndroidRuntime(863):  ... 14 more

To not leave this question unanswered...

It runs on your desktop version, because your desktop version is Micosoft Windows and they do not care about the case in file names. data/Texture.png is the same as data/tEXtUre.png for Windows and thus it works without any problems.

Every other OS that I know of, cares about the case in filenames and thus on Android you don't find the file when loading it as data/texture.png when it is actually named data/Texture.png .

I'd advise you to always use lower case only when it's about files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM