1

我得到了“著名”报告ANR keyDispatchingTimedOut,我正在阅读它,但我不太了解,我想问一下。我猜这个问题是由 onCreate() 上的大量工作引起的?如果我创建一个新方法,我可以避免这个错误吗?这是我第一次遇到这种类型的错误,我有点困惑。

DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x40ab8478 self=0x1bde910
  | sysTid=332 nice=0 sched=0/0 cgrp=default handle=1074341224
  | schedstat=( 0 0 0 ) utm=33 stm=24 core=0
  at com.google.android.gles_jni.EGLImpl.eglInitialize(Native Method)
  at android.view.HardwareRenderer$GlRenderer.initializeEgl(HardwareRenderer.java:564)
  at android.view.HardwareRenderer$GlRenderer.initialize(HardwareRenderer.java:512)
  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1342)
  at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2558)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:137)
  at android.app.ActivityThread.main(ActivityThread.java:4697)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:511)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
  at dalvik.system.NativeStart.main(Native Method)

"Thread-8316" prio=5 tid=17 SUSPENDED
  | group="main" sCount=1 dsCount=0 obj=0x413eedf0 self=0x1d45d20
  | sysTid=464 nice=0 sched=0/0 cgrp=default handle=30694368
  | schedstat=( 0 0 0 ) utm=14 stm=9 core=0
  at org.apache.harmony.xml.parsers.DocumentBuilderFactoryImpl.<init>(DocumentBuilderFactoryImpl.java:~29)
  at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:54)
  at com.tapjoy.TapjoyUtil.buildDocument(TapjoyUtil.java:130)
  at com.tapjoy.TapjoyConnectCore.handleConnectResponse(TapjoyConnectCore.java:633)
  at com.tapjoy.TapjoyConnectCore.access$5(TapjoyConnectCore.java:630)
  at com.tapjoy.TapjoyConnectCore$ConnectThread.run(TapjoyConnectCore.java:1209)
  at java.lang.Thread.run(Thread.java:856)

"Thread-8314" prio=5 tid=16 TIMED_WAIT
  | group="main" sCount=1 dsCount=0 obj=0x41607538 self=0x1df7660
  | sysTid=436 nice=0 sched=0/0 cgrp=default handle=31423368
  | schedstat=( 0 0 0 ) utm=1 stm=0 core=0
  at java.lang.Object.wait(Native Method)
  - waiting on <0x4160c4c8> (a com.google.ads.internal.c)
  at java.lang.Object.wait(Object.java:401)
  at com.google.ads.internal.c.run(SourceFile:547)
  at java.lang.Thread.run(Thread.java:856)

"Thread-8313" prio=5 tid=13 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x4160be80 self=0x1dadd78
  | sysTid=433 nice=0 sched=0/0 cgrp=default handle=31250304
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=0
  at android.os.BinderProxy.transact(Native Method)
  at android.content.ContentProviderProxy.query(ContentProviderNative.java:360)
  at android.content.ContentResolver.query(ContentResolver.java:311)
  at com.google.ads.ae$a.run(SourceFile:94)
  at java.lang.Thread.run(Thread.java:856)

"AsyncTask #1" prio=5 tid=15 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x415e6cc8 self=0x1df32b8
  | sysTid=397 nice=10 sched=0/0 cgrp=bg_non_interactive handle=30224856
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=1
  at java.lang.Object.wait(Native Method)
  - waiting on <0x415e7198> (a java.lang.VMThread) held by tid=15 (AsyncTask #1)
  at java.lang.Thread.parkFor(Thread.java:1231)
  at sun.misc.Unsafe.park(Unsafe.java:323)
  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
  at java.lang.Thread.run(Thread.java:856)

"CookieSyncManager" prio=5 tid=14 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x415e5418 self=0x1df63a0
  | sysTid=396 nice=10 sched=0/0 cgrp=bg_non_interactive handle=30228264
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=0
  at android.os.MessageQueue.nativePollOnce(Native Method)
  at android.os.MessageQueue.next(MessageQueue.java:118)
  at android.os.Looper.loop(Looper.java:118)
  at android.webkit.WebSyncManager.run(WebSyncManager.java:90)
  at android.webkit.CookieSyncManager.run(CookieSyncManager.java:61)
  at java.lang.Thread.run(Thread.java:856)

"WebViewCoreThread" prio=5 tid=12 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x415df248 self=0x1daa3d8
  | sysTid=394 nice=0 sched=0/0 cgrp=default handle=30230200
  | schedstat=( 0 0 0 ) utm=21 stm=5 core=0
  at android.os.MessageQueue.nativePollOnce(Native Method)
  at android.os.MessageQueue.next(MessageQueue.java:118)
  at android.os.Looper.loop(Looper.java:118)
  at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:728)
  at java.lang.Thread.run(Thread.java:856)

"SoundPoolThread" prio=5 tid=11 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x415d71e0 self=0x1defde0
  | sysTid=392 nice=0 sched=0/0 cgrp=default handle=30224688
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=0
  at dalvik.system.NativeStart.run(Native Method)

"SoundPool" prio=5 tid=10 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x415d5ea8 self=0x1e044a8
  | sysTid=391 nice=0 sched=0/0 cgrp=default handle=30214880
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=1
  at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #2" prio=5 tid=9 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x413c34c8 self=0x1dcbc18
  | sysTid=358 nice=0 sched=0/0 cgrp=default handle=31465352
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=0
  at dalvik.system.NativeStart.run(Native Method)

"Binder Thread #1" prio=5 tid=8 NATIVE
  | group="main" sCount=1 dsCount=0 obj=0x413c32e8 self=0x1e02808
  | sysTid=357 nice=0 sched=0/0 cgrp=default handle=31182208
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=0
  at dalvik.system.NativeStart.run(Native Method)

"FinalizerWatchdogDaemon" daemon prio=5 tid=7 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x413bfe08 self=0x1d45578
  | sysTid=356 nice=0 sched=0/0 cgrp=default handle=31066824
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=0
  at java.lang.Object.wait(Native Method)
  - waiting on <0x40abfe00> (a java.lang.Daemons$FinalizerWatchdogDaemon)
  at java.lang.Object.wait(Object.java:364)
  at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:213)
  at java.lang.Thread.run(Thread.java:856)

"FinalizerDaemon" daemon prio=5 tid=6 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x413bfcb0 self=0x1df83d0
  | sysTid=350 nice=0 sched=0/0 cgrp=default handle=31033000
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=1
  at java.lang.Object.wait(Native Method)
  - waiting on <0x40aae5e8> (a java.lang.ref.ReferenceQueue)
  at java.lang.Object.wait(Object.java:401)
  at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:102)
  at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:73)
  at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
  at java.lang.Thread.run(Thread.java:856)

"ReferenceQueueDaemon" daemon prio=5 tid=5 WAIT
  | group="main" sCount=1 dsCount=0 obj=0x413bfb48 self=0x1d49858
  | sysTid=349 nice=0 sched=0/0 cgrp=default handle=30767328
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=1
  at java.lang.Object.wait(Native Method)
  - waiting on <0x40aae510> 
  at java.lang.Object.wait(Object.java:364)
  at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:128)
  at java.lang.Thread.run(Thread.java:856)

"Compiler" daemon prio=5 tid=4 VMWAIT
  | group="system" sCount=1 dsCount=0 obj=0x413bfa58 self=0x1df9268
  | sysTid=348 nice=0 sched=0/0 cgrp=default handle=30822480
  | schedstat=( 0 0 0 ) utm=15 stm=2 core=0
  at dalvik.system.NativeStart.run(Native Method)

"Signal Catcher" daemon prio=5 tid=3 RUNNABLE
  | group="system" sCount=0 dsCount=0 obj=0x413bf960 self=0x1d599c0
  | sysTid=347 nice=0 sched=0/0 cgrp=default handle=29878568
  | schedstat=( 0 0 0 ) utm=0 stm=0 core=0
  at dalvik.system.NativeStart.run(Native Method)

"GC" daemon prio=5 tid=2 VMWAIT
  | group="system" sCount=1 dsCount=0 obj=0x413bf880 self=0x1de7130
  | sysTid=336 nice=0 sched=0/0 cgrp=default handle=30872008
  | schedstat=( 0 0 0 ) utm=1 stm=1 core=0
  at dalvik.system.NativeStart.run(Native Method)

我不知道在哪里看到这条消息的问题,我的应用程序只有一个主要活动。

非常感谢大家:)

4

1 回答 1

2

我认为发布您的代码会在这里为您提供最佳答案,但您也可能不了解使用多个线程来防止主线程(GUI)变得无响应。我发现本教程最有帮助。

http://www.vogella.com/articles/AndroidPerformance/article.html

对于刚入门的 Android 程序员,甚至是经验丰富的程序员来说,这都是一个棘手的问题,但一旦你掌握了窍门,它就不会那么糟糕了。

于 2012-07-22T12:00:10.013 回答