I am a beginner with Android. I had done a couple of small projects to learn android. But when i tried to do one of the earlier projects again, the emulator showed app failure. I tried bluestacks, yet the same. And when I tried to run some of my previous apps which was already installed in the emulator, I figured out that, none of those apps, which were previously working is working right now. I tried debugging one of the apps, that was previously working, without making any change in the code, and got the logcat output as below(Sorry for pasting the entire thing, but I cant actually figure out the actual problem):
我是Android的初学者。我做了几个小项目来学习android。但是当我再次尝试做一个早期的项目时,仿真器显示应用程序失败。我试过蓝的,但还是一样。当我试着运行我之前已经安装在模拟器中的应用程序时,我发现,那些以前工作的应用程序现在都不工作了。我试过调试其中的一个应用程序,它以前是工作的,没有在代码中做任何修改,并且得到了下面的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
I tried Googling for CPU may be pegged
error, but didn't get an actual answer. And rather, all of them were talking about the same error in some advanced apps using audio and all, but the program i tried to debug was a simple Hello World app. And somewhere someone told to close and reopen the eclipse and emulator, reboot the system, I tried everything, still no luck. I am stuck up with this for the last couple of days. Google d every possibilities in the logcat and got no answer. If anyone knows what can be the issue, please help.
我试着用谷歌搜索CPU,但没有得到实际的答案。,相反,他们所有人都在谈论同样的错误在一些高级应用程序使用音频和所有,但我试着调试的程序是一个简单的Hello World应用程序。有人告诉问题,关闭并重新打开eclipse和模拟器,启动系统时,我试着一切,仍然没有运气。在过去的几天里,我一直被这个问题困扰着。所有的可能性都在logcat里,没有答案。如果有人知道什么是问题,请帮忙。
And if this is of use, this is the screenshot of the debugger screen.
如果这是有用的,这是调试器屏幕截图。
1 个解决方案
#1
2
You appear to be calling findViewById
inside the constructor of the Activity. You should be doing this later (preferably in onCreate()
), and only after calling setContentView()
.
您似乎在活动的构造函数中调用findViewById。您应该稍后再做(最好是在onCreate()中),并且只在调用setContentView()之后。
#1
2
You appear to be calling findViewById
inside the constructor of the Activity. You should be doing this later (preferably in onCreate()
), and only after calling setContentView()
.
您似乎在活动的构造函数中调用findViewById。您应该稍后再做(最好是在onCreate()中),并且只在调用setContentView()之后。