我已启用StrictMode并捕获此日志(/data/anr/traces.txt)。问题是列表视图在处理大约3行(第4行)后挂起。我正在使用持有人模式。其他地方的列表视图似乎工作正常。
感谢任何帮助。
JNI: CheckJNI is off; workarounds are off; pins=0; globals=320
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 SUSPENDED
| group="main" sCount=1 dsCount=0 obj=0x41ddbca8 self=0x41dca3c8
| sysTid=22827 nice=0 sched=0/0 cgrp=apps handle=1075642708
| state=S schedstat=( 38273640000 1091756000 67689 ) utm=3677 stm=150 core=1
at android.view.View.getContext(View.java:~8153)
at android.view.View.getLayoutDirection(View.java:6247)
at android.widget.RelativeLayout.getRelatedView(RelativeLayout.java:997)
at android.widget.RelativeLayout.getRelatedViewBaseline(RelativeLayout.java:1021)
at android.widget.RelativeLayout.alignBaseline(RelativeLayout.java:642)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:519)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16497)
at android.widget.ListView.setupChild(ListView.java:1870)
at android.widget.ListView.makeAndAddView(ListView.java:1793)
at android.widget.ListView.fillDown(ListView.java:691)
at android.widget.ListView.fillFromTop(ListView.java:752)
at android.widget.ListView.layoutChildren(ListView.java:1616)
at android.widget.AbsListView.onLayout(AbsListView.java:2091)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:374)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
"AsyncTask #2" prio=5 tid=22 WAIT
| group="main" sCount=1 dsCount=0 obj=0x42852b80 self=0x68644920
| sysTid=22961 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1751403896
| state=S schedstat=( 581366000 108708000 6378 ) utm=40 stm=18 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x428790f8> (a java.lang.VMThread) held by tid=22 (AsyncTask #2)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2017)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
"OkHttp ConnectionPool" daemon prio=5 tid=16 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x427d6790 self=0x68523a28
| sysTid=22927 nice=0 sched=0/0 cgrp=apps handle=1750220416
| state=S schedstat=( 7097000 2266000 145 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x4284f478> (a java.lang.VMThread) held by tid=16 (OkHttp ConnectionPool)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:197)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2056)
at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:435)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1035)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1097)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
发现问题。 堆栈跟踪提供了一些线索alignBase()。发生的事情是对齐是基于一个不可见并引用自己的小部件。所以主线程进入挂起状态。
答案 0 :(得分:0)
即。申请没有回应......
如果您在主(UI)线程上尝试执行需要很长时间(例如从远程服务器下载映像/数据)的任务,则会发生此ANR
要摆脱这种尝试,请为这些长时间运行的任务使用asyntask / thread。
答案 1 :(得分:0)
发现问题。堆栈跟踪提供了一些线索,alignBase()调用。发生的事情是,对齐是基于一个不可见并引用自己的小部件(评级栏)。所以主线程进入挂起状态。
Stacktrace非常有用,一旦你知道如何阅读它,它的全部内容都是追溯到你的代码中调用的位置。在我的情况下,它涉及很少,因为所涉及的所有类都是android。