LogCat output debugging help

2019-09-19 06:06发布

问题:

My Logcat output for my program failing. It apparently can't access some kind of SD card, but I'm using the emulator. I'm on x64 windows 7, and I ran as administrator.

08-29 19:16:29.360: ERROR/AndroidRuntime(707): FATAL EXCEPTION: GLThread 10
08-29 19:16:29.360: ERROR/AndroidRuntime(707): java.lang.ExceptionInInitializerError
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at com.wickeyware.zombiearcher.screen.TitleScreen.render(TitleScreen.java:80)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at com.wickeyware.zombiearcher.ZombieArcher.render(ZombieArcher.java:49)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:419)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
08-29 19:16:29.360: ERROR/AndroidRuntime(707): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error writing file: za_data (External)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at com.badlogic.gdx.files.FileHandle.write(FileHandle.java:157)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at com.wickeyware.zombiearcher.statistics.Statistics.<clinit>(Statistics.java:70)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     ... 5 more
08-29 19:16:29.360: ERROR/AndroidRuntime(707): Caused by: java.io.FileNotFoundException: /mnt/sdcard/za_data (Permission denied)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:232)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at java.io.FileOutputStream.<init>(FileOutputStream.java:94)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     at com.badlogic.gdx.files.FileHandle.write(FileHandle.java:153)
08-29 19:16:29.360: ERROR/AndroidRuntime(707):     ... 6 more

回答1:

In FileHandle.java in your code you're trying to write something to the SD card (line 153). The error "Permission Denied", therefore I assume you didn't add the correct permission to your AndroidManifest.xml. Add:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

And it should be ok. Make sure you have an SD card configured in the emulator (using the AVD)