Android应用程序根本不运行 - 可能会挂起CPU

时间:2014-04-12 07:57:11

标签: android eclipse android-emulator adt bluestacks

我是Android的初学者。我做了几个小项目来学习android。但是,当我再次尝试执行其中一个早期项目时,模拟器显示应用程序失败。我试过bluestacks,但是一样。当我试图运行我之前已经安装在模拟器中的一些应用程序时,我发现,之前正在运行的那些应用程序中没有一个正在运行。我尝试调试其中一个以前正在工作的应用程序,而不对代码进行任何更改,并获得如下的logcat输出(对不起粘贴整个事情,但我实际上无法弄清楚实际问题):

04-12 12:37:42.340: D/dalvikvm(7591): GC_CONCURRENT freed 435K, 55% free 2670K/5831K, external 716K/1038K, paused 0ms+0ms
04-12 12:37:42.750: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 2 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:43.760: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 3 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:44.770: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 4 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:44.880: I/InputDispatcher(7156): Application is not responding: AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}.  425890.0ms since event, 425890.0ms since wait started
04-12 12:37:44.880: I/WindowManager(7156): Input event dispatching timed out sending to application AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}
04-12 12:37:45.780: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 5 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:46.790: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 6 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:47.800: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 7 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:48.810: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 8 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:49.820: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 9 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:49.890: I/InputDispatcher(7156): Application is not responding: AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}.  430900.0ms since event, 430900.0ms since wait started
04-12 12:37:49.890: I/WindowManager(7156): Input event dispatching timed out sending to application AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}
04-12 12:37:50.830: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 10 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:51.840: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 11 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:52.850: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 12 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:53.860: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 13 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:54.870: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 14 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:54.920: I/InputDispatcher(7156): Application is not responding: AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}.  435930.0ms since event, 435930.0ms since wait started
04-12 12:37:54.920: I/WindowManager(7156): Input event dispatching timed out sending to application AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}
04-12 12:37:55.880: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 15 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:56.890: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 16 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:57.900: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 17 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:58.910: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 18 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:59.200: D/SntpClient(7156): request time failed: java.net.SocketException: Address family not supported by protocol
04-12 12:37:59.920: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 19 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:37:59.930: I/InputDispatcher(7156): Application is not responding: AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}.  440940.0ms since event, 440940.0ms since wait started
04-12 12:37:59.930: I/WindowManager(7156): Input event dispatching timed out sending to application AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}
04-12 12:38:00.930: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 20 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:38:01.940: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 21 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:38:02.950: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 22 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:38:03.960: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 23 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:38:04.940: I/InputDispatcher(7156): Application is not responding: AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}.  445950.0ms since event, 445950.0ms since wait started
04-12 12:38:04.940: I/WindowManager(7156): Input event dispatching timed out sending to application AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}
04-12 12:38:04.970: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 24 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:38:05.980: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 25 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:38:06.990: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 26 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:38:08.000: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 27 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:38:09.010: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 28 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:38:09.950: I/InputDispatcher(7156): Application is not responding: AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}.  450960.0ms since event, 450960.0ms since wait started
04-12 12:38:09.950: I/WindowManager(7156): Input event dispatching timed out sending to application AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}
04-12 12:38:10.010: W/ActivityManager(7156): Timeout of broadcast BroadcastRecord{b493a1a0 android.intent.action.TIME_TICK} - receiver=android.os.BinderProxy@b460ef08, started 10010ms ago
04-12 12:38:10.010: I/Process(7156): Sending signal. PID: 8635 SIG: 3
04-12 12:38:10.010: I/dalvikvm(8635): threadid=4: reacting to signal 3
04-12 12:38:10.010: I/dalvikvm(8635): Wrote stack traces to '/data/anr/traces.txt'
04-12 12:38:10.010: I/Process(7156): Sending signal. PID: 7156 SIG: 3
04-12 12:38:10.010: I/dalvikvm(7156): threadid=4: reacting to signal 3
04-12 12:38:10.010: I/dalvikvm(7156): Wrote stack traces to '/data/anr/traces.txt'
04-12 12:38:10.010: W/ActivityManager(7156): Receiver during timeout: BroadcastFilter{b47fe0e8 ReceiverList{b4804a98 8635 com.android.systemui/1000 remote:b460ef08}}
04-12 12:38:10.020: W/SharedBufferStack(8635): waitForCondition(LockCondition) timed out 29 times(identity=16, status=0). CPU may be pegged. trying again.
04-12 12:38:10.040: D/dalvikvm(7156): GC_EXPLICIT freed 1141K, 49% free 6226K/11975K, external 1868K/2380K, paused 10ms
04-12 12:38:10.560: I/Process(7156): Sending signal. PID: 8635 SIG: 9
04-12 12:38:10.560: E/InputDispatcher(7156): channel 'b462dea0 StatusBar (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
04-12 12:38:10.560: E/InputDispatcher(7156): channel 'b462dea0 StatusBar (server)' ~ Channel is unrecoverably broken and will be disposed!
04-12 12:38:10.560: E/InputDispatcher(7156): channel 'b47e8660 TrackingView (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
04-12 12:38:10.560: E/InputDispatcher(7156): channel 'b47e8660 TrackingView (server)' ~ Channel is unrecoverably broken and will be disposed!
04-12 12:38:10.560: E/InputDispatcher(7156): channel 'b48c8bf0 StatusBarExpanded (server)' ~ Consumer closed input channel or an error occurred.  events=0x8
04-12 12:38:10.560: E/InputDispatcher(7156): channel 'b48c8bf0 StatusBarExpanded (server)' ~ Channel is unrecoverably broken and will be disposed!
04-12 12:38:10.560: E/ActivityManager(7156): ANR in com.android.systemui
04-12 12:38:10.560: E/ActivityManager(7156): Reason: Broadcast of Intent { act=android.intent.action.TIME_TICK flg=0x40000004 (has extras) }
04-12 12:38:10.560: E/ActivityManager(7156): Load: 3.05 / 3.23 / 3.31
04-12 12:38:10.560: E/ActivityManager(7156): CPU usage from 5000ms to -540ms ago:
04-12 12:38:10.560: E/ActivityManager(7156):   0.7% 7156/system_server: 0.5% user + 0.1% kernel / faults: 127 minor
04-12 12:38:10.560: E/ActivityManager(7156): 0.5% TOTAL: 0.5% user + 0% kernel
04-12 12:38:10.560: E/ActivityManager(7156): CPU usage from 30ms to 540ms later:
04-12 12:38:10.560: E/ActivityManager(7156): 0% TOTAL: 0% user + 0% kernel
04-12 12:38:10.560: I/WindowManager(7156): WINDOW DIED Window{b462dea0 StatusBar paused=false}
04-12 12:38:10.560: I/WindowManager(7156): WINDOW DIED Window{b47e8660 TrackingView paused=false}
04-12 12:38:10.560: I/WindowManager(7156): WINDOW DIED Window{b48c8bf0 StatusBarExpanded paused=false}
04-12 12:38:10.560: I/ActivityManager(7156): Process com.android.systemui (pid 8635) has died.
04-12 12:38:10.560: W/ActivityManager(7156): Scheduling restart of crashed service com.android.systemui/.statusbar.StatusBarService in 320000ms
04-12 12:38:10.560: I/ActivityManager(7156): Start proc com.android.systemui for restart com.android.systemui: pid=8647 uid=1000 gids={3002, 3001, 3003, 1015}
04-12 12:38:10.560: W/ActivityManager(7156): Failure sending broadcast Intent { act=android.intent.action.TIME_TICK flg=0x40000004 (has extras) }
04-12 12:38:10.560: W/ActivityManager(7156): android.os.DeadObjectException
04-12 12:38:10.560: W/ActivityManager(7156): at android.os.BinderProxy.transact(Native Method)
04-12 12:38:10.560: W/ActivityManager(7156): at android.content.IIntentReceiver$Stub$Proxy.performReceive(IIntentReceiver.java:121)
04-12 12:38:10.560: W/ActivityManager(7156): at com.android.server.am.ActivityManagerService.performReceiveLocked(ActivityManagerService.java:10955)
04-12 12:38:10.560: W/ActivityManager(7156): at com.android.server.am.ActivityManagerService.deliverToRegisteredReceiverLocked(ActivityManagerService.java:11017)
04-12 12:38:10.560: W/ActivityManager(7156): at com.android.server.am.ActivityManagerService.processNextBroadcast(ActivityManagerService.java:11223)
04-12 12:38:10.560: W/ActivityManager(7156): at com.android.server.am.ActivityManagerService.access$100(ActivityManagerService.java:146)
04-12 12:38:10.560: W/ActivityManager(7156): at com.android.server.am.ActivityManagerService$2.handleMessage(ActivityManagerService.java:1089)
04-12 12:38:10.560: W/ActivityManager(7156): at android.os.Handler.dispatchMessage(Handler.java:99)
04-12 12:38:10.560: W/ActivityManager(7156): at android.os.Looper.loop(Looper.java:130)
04-12 12:38:10.560: W/ActivityManager(7156): at com.android.server.am.ActivityManagerService$AThread.run(ActivityManagerService.java:1344)
04-12 12:38:12.400: D/dalvikvm(7591): GC_CONCURRENT freed 436K, 55% free 2670K/5831K, external 716K/1038K, paused 0ms+0ms
04-12 12:38:14.960: I/InputDispatcher(7156): Application is not responding: AppWindowToken{b48db298 token=HistoryRecord{b4899e68 com.example.asd/.MainActivity}}.  455970.0ms since event, 455970.0ms since wait started
04-12 12:48:50.160: D/dalvikvm(8181): Debugger has detached; object registry had 180 entries
04-12 12:48:50.160: I/dalvikvm(8181): ignoring registerObject request in thread=1
04-12 12:48:50.160: I/dalvikvm(8181): ignoring registerObject request in thread=1
04-12 12:48:50.160: D/AndroidRuntime(8181): Shutting down VM
04-12 12:48:50.160: W/dalvikvm(8181): threadid=1: thread exiting with uncaught exception (group=0xb3f724f0)
04-12 12:48:50.160: D/AndroidRuntime(8181): procName from cmdline: com.example.asd
04-12 12:48:50.160: E/AndroidRuntime(8181): in writeCrashedAppName, pkgName :com.example.asd
04-12 12:48:50.160: D/AndroidRuntime(8181): file written successfully with content: com.example.asd StringBuffer : ;com.example.asd
04-12 12:48:50.170: I/Process(8181): Sending signal. PID: 8181 SIG: 9
04-12 12:48:50.170: E/AndroidRuntime(8181): FATAL EXCEPTION: main
04-12 12:48:50.170: E/AndroidRuntime(8181): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.asd/com.example.asd.MainActivity}: java.lang.NullPointerException
04-12 12:48:50.170: E/AndroidRuntime(8181): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
04-12 12:48:50.170: E/AndroidRuntime(8181): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-12 12:48:50.170: E/AndroidRuntime(8181): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-12 12:48:50.170: E/AndroidRuntime(8181): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-12 12:48:50.170: E/AndroidRuntime(8181): at android.os.Handler.dispatchMessage(Handler.java:99)
04-12 12:48:50.170: E/AndroidRuntime(8181): at android.os.Looper.loop(Looper.java:130)
04-12 12:48:50.170: E/AndroidRuntime(8181): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-12 12:48:50.170: E/AndroidRuntime(8181): at java.lang.reflect.Method.invokeNative(Native Method)
04-12 12:48:50.170: E/AndroidRuntime(8181): at java.lang.reflect.Method.invoke(Method.java:507)
04-12 12:48:50.170: E/AndroidRuntime(8181): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
04-12 12:48:50.170: E/AndroidRuntime(8181): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:638)
04-12 12:48:50.170: E/AndroidRuntime(8181): at dalvik.system.NativeStart.main(Native Method)
04-12 12:48:50.170: E/AndroidRuntime(8181): Caused by: java.lang.NullPointerException
04-12 12:48:50.170: E/AndroidRuntime(8181): at android.app.Activity.findViewById(Activity.java:1650)
04-12 12:48:50.170: E/AndroidRuntime(8181): at com.example.asd.MainActivity.<init>(MainActivity.java:18)
04-12 12:48:50.170: E/AndroidRuntime(8181): at java.lang.Class.newInstanceImpl(Native Method)
04-12 12:48:50.170: E/AndroidRuntime(8181): at java.lang.Class.newInstance(Class.java:1409)
04-12 12:48:50.170: E/AndroidRuntime(8181): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
04-12 12:48:50.170: E/AndroidRuntime(8181): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
04-12 12:48:50.170: E/AndroidRuntime(8181): ... 11 more

我尝试使用谷歌搜索CPU may be pegged错误,但没有得到实际答案。而且,所有这些都在谈论使用音频和所有的一些高级应用程序中的相同错误,但我尝试调试的程序是一个简单的Hello World应用程序。有人告诉关闭并重新打开日食和模拟器,重启系统,我尝试了一切,仍然没有运气。在过去的几天里,我对此感到困惑。谷歌在logcat中的每一种可能性都得不到答案。如果有人知道可能是什么问题,请帮助。

如果这是有用的,这是调试器屏幕的屏幕截图。 enter image description here

1 个答案:

答案 0 :(得分:2)

您似乎在Activity的构造函数中调用了findViewById。您应该稍后(最好是onCreate()),并且仅在致电setContentView()后才这样做。