Android 在以下日志片段中指向错误消息

Android 在以下日志片段中指向错误消息,android,android-layout,android-emulator,Android,Android Layout,Android Emulator,下面是我尝试运行应用程序时日志生成的内容。应用程序意外失败,甚至无法启动 09-02 04:28:51.856: D/dalvikvm(781): GC_FOR_ALLOC freed 66K, 7% free 2542K/2728K, paused 51ms, total 66ms 09-02 04:28:51.866: I/dalvikvm-heap(781): Grow heap (frag case) to 3.181MB for 614500-byte allocation 09-02

下面是我尝试运行应用程序时日志生成的内容。应用程序意外失败,甚至无法启动

09-02 04:28:51.856: D/dalvikvm(781): GC_FOR_ALLOC freed 66K, 7% free 2542K/2728K, paused 51ms, total 66ms
09-02 04:28:51.866: I/dalvikvm-heap(781): Grow heap (frag case) to 3.181MB for 614500-byte allocation
09-02 04:28:51.936: D/dalvikvm(781): GC_FOR_ALLOC freed <1K, 6% free 3142K/3332K, paused 67ms, total 67ms
09-02 04:28:52.406: W/SoundPool(781):   sample 1 not READY
09-02 04:28:53.116: D/gralloc_goldfish(781): Emulator without GPU emulation detected.
09-02 04:28:53.376: I/Choreographer(781): Skipped 33 frames!  The application may be doing too much work on its main thread.
09-02 04:29:22.606: E/AudioTrack(781): Could not get audio output for stream type 3
09-02 04:29:22.606: E/SoundPool(781): Error creating AudioTrack
09-02 04:29:22.756: D/dalvikvm(781): GC_FOR_ALLOC freed 30K, 5% free 3523K/3672K, paused 19ms, total 21ms
09-02 04:29:22.756: I/dalvikvm-heap(781): Grow heap (frag case) to 4.159MB for 635812-byte allocation
09-02 04:29:22.856: D/dalvikvm(781): GC_FOR_ALLOC freed 1K, 4% free 4143K/4296K, paused 97ms, total 97ms
09-02 04:29:22.966: I/Choreographer(781): Skipped 91 frames!  The application may be doing too much work on its main thread.
09-02 04:29:23.206: I/Choreographer(781): Skipped 55 frames!  The application may be doing too much work on its main thread.
09-02 04:29:23.375: I/Choreographer(781): Skipped 35 frames!  The application may be doing too much work on its main thread.
09-02 04:29:23.776: I/Choreographer(781): Skipped 79 frames!  The application may be doing too much work on its main thread.
09-02 04:29:28.016: D/dalvikvm(781): GC_FOR_ALLOC freed 108K, 5% free 4436K/4664K, paused 111ms, total 133ms
09-02 04:29:28.045: I/dalvikvm-heap(781): Grow heap (frag case) to 5.030MB for 614500-byte allocation
09-02 04:29:28.096: D/dalvikvm(781): GC_FOR_ALLOC freed 1K, 5% free 5034K/5268K, paused 55ms, total 56ms
09-02 04:29:28.235: W/SoundPool(781):   sample 1 not READY
09-02 04:29:28.785: I/Choreographer(781): Skipped 50 frames!  The application may be doing too much work on its main thread.
09-02 04:29:31.626: E/AudioTrack(781): Could not get audio output for stream type 3
09-02 04:29:31.626: E/SoundPool(781): Error creating AudioTrack
09-02 04:29:31.746: E/SlaveBlueTooth(781): +++ ON CREATE +++
09-02 04:29:31.766: W/System.err(781): java.io.IOException: open failed: EROFS (Read-only file system)
09-02 04:29:31.776: W/System.err(781):  at java.io.File.createNewFile(File.java:948)
09-02 04:29:31.785: W/System.err(781):  at helog.diwesh.NugaBest.BTSmartSlavemodule.onCreate(BTSmartSlavemodule.java:118)
09-02 04:29:31.796: W/System.err(781):  at android.app.Activity.performCreate(Activity.java:5133)
09-02 04:29:31.796: W/System.err(781):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-02 04:29:31.796: W/System.err(781):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
09-02 04:29:31.816: W/System.err(781):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
09-02 04:29:31.816: W/System.err(781):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-02 04:29:31.816: W/System.err(781):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-02 04:29:31.826: W/System.err(781):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-02 04:29:31.826: W/System.err(781):  at android.os.Looper.loop(Looper.java:137)
09-02 04:29:31.826: W/System.err(781):  at android.app.ActivityThread.main(ActivityThread.java:5103)
09-02 04:29:31.836: W/System.err(781):  at java.lang.reflect.Method.invokeNative(Native Method)
09-02 04:29:31.836: W/System.err(781):  at java.lang.reflect.Method.invoke(Method.java:525)
09-02 04:29:31.846: W/System.err(781):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-02 04:29:31.846: W/System.err(781):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-02 04:29:31.856: W/System.err(781):  at dalvik.system.NativeStart.main(Native Method)
09-02 04:29:31.856: W/System.err(781): Caused by: libcore.io.ErrnoException: open failed: EROFS (Read-only file system)
09-02 04:29:31.876: W/System.err(781):  at libcore.io.Posix.open(Native Method)
09-02 04:29:31.886: W/System.err(781):  at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
09-02 04:29:31.886: W/System.err(781):  at java.io.File.createNewFile(File.java:941)
09-02 04:29:31.896: W/System.err(781):  ... 15 more
09-02 04:29:32.016: D/AndroidRuntime(781): Shutting down VM
09-02 04:29:32.016: W/dalvikvm(781): threadid=1: thread exiting with uncaught exception (group=0x41465700)
09-02 04:29:32.066: E/AndroidRuntime(781): FATAL EXCEPTION: main
09-02 04:29:32.066: E/AndroidRuntime(781): java.lang.RuntimeException: Unable to start activity ComponentInfo{hellog.diwesh.NugaBest/helog.diwesh.NugaBest.BTSmartSlavemodule}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.os.Handler.dispatchMessage(Handler.java:99)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.os.Looper.loop(Looper.java:137)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.app.ActivityThread.main(ActivityThread.java:5103)
09-02 04:29:32.066: E/AndroidRuntime(781):  at java.lang.reflect.Method.invokeNative(Native Method)
09-02 04:29:32.066: E/AndroidRuntime(781):  at java.lang.reflect.Method.invoke(Method.java:525)
09-02 04:29:32.066: E/AndroidRuntime(781):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-02 04:29:32.066: E/AndroidRuntime(781):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-02 04:29:32.066: E/AndroidRuntime(781):  at dalvik.system.NativeStart.main(Native Method)
09-02 04:29:32.066: E/AndroidRuntime(781): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
09-02 04:29:32.066: E/AndroidRuntime(781):  at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:226)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.app.Activity.requestWindowFeature(Activity.java:3264)
09-02 04:29:32.066: E/AndroidRuntime(781):  at helog.diwesh.NugaBest.BTSmartSlavemodule.onCreate(BTSmartSlavemodule.java:141)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.app.Activity.performCreate(Activity.java:5133)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
09-02 04:29:32.066: E/AndroidRuntime(781):  ... 11 more
09-02 04:28:51.856:D/dalvikvm(781):全部释放66K,7%释放2542K/2728K,暂停51ms,总计66ms
09-02 04:28:51.866:I/dalvikvm堆(781):为614500字节分配将堆(frag案例)增长到3.181MB

09-02 04:28:51.936:D/dalvikvm(781):GC_FOR_ALLOC freed这是您的日志中的错误:

 FATAL EXCEPTION: main
09-02 04:29:32.066: E/AndroidRuntime(781): java.lang.RuntimeException: Unable to start activity ComponentInfo{hellog.diwesh.NugaBest/helog.diwesh.NugaBest.BTSmartSlavemodule}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
这里有多个问题:

09-02 04:29:31.766: W/System.err(781): java.io.IOException: open failed: EROFS (Read-only file system)
09-02 04:29:31.776: W/System.err(781):  at java.io.File.createNewFile(File.java:948)
09-02 04:29:31.785: W/System.err(781):  at helog.diwesh.NugaBest.BTSmartSlavemodule.onCreate(BTSmartSlavemodule.java:118)
BTSmartSlavemodule.java
第118行中,您试图在只读文件系统上创建一个新文件

09-02 04:29:32.066: E/AndroidRuntime(781): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
09-02 04:29:32.066: E/AndroidRuntime(781):  at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:226)
09-02 04:29:32.066: E/AndroidRuntime(781):  at android.app.Activity.requestWindowFeature(Activity.java:3264)
09-02 04:29:32.066: E/AndroidRuntime(781):  at helog.diwesh.NugaBest.BTSmartSlavemodule.onCreate(BTSmartSlavemodule.java:141)

在调用
setContentView()
后,在试图调用
requestWindowFeature()
的同一文件的第141行。您需要在调用requestFeature()之前设置窗口功能。
setContentView()

调用requestFeature()的位置不正确。。。请在
setContentView(R.layout.activity)
之前尝试调用此方法。此错误的原因是:

09-02 04:29:32.066: E/AndroidRuntime(781): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
这个原因发生在:

09-02 04:29:31.785: W/System.err(781):  at helog.diwesh.NugaBest.BTSmartSlavemodule.onCreate(BTSmartSlavemodule.java:118)

放置代码的位置。
requestWindowFeature()
。为了避免这一原因,您必须将此代码放在
setContentView(R.layout.your_layout)之前

我认为您正在尝试在SD卡上创建文件,但您没有在清单文件中写入外部存储的指定权限

将此行添加到manifest.xml文件

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

java.io.IOException:打开失败:EROFS(只读文件系统)