ANR意向广播
我在我的应用程序中有一个BroadcastReceiver,它每隔X秒由一个ALARM_SERVICE调用。 这个BroadcastReceiver调用另一个由AsyncTask运行的服务(为了避免阻塞主线程),但我收到了一些来自我的用户的ANR以及谷歌提供给我的日志,我无法阅读它,诚实。
有人能帮我理解日志并解决问题吗?
这是Google为我提供的11个日志中的1个:
DALVIK THREADS :(互斥锁:tll = 0 tsl = 0 tscl = 0 ghl = 0)
"main" prio=5 tid=1 WAIT
| group="main" sCount=1 dsCount=0 obj=0x418c8578 self=0x4179e1c0
| sysTid=24081 nice=0 sched=0/0 cgrp=apps handle=1074630652
| state=S schedstat=( 0 0 0 ) utm=1049 stm=265 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x418c8978> (a java.lang.VMThread) held by tid=1 (main)
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:159)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:810)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:843)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1173)
at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:183)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:259)
at android.view.SurfaceView.updateWindow(SurfaceView.java:499)
at android.view.SurfaceView.access$000(SurfaceView.java:86)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:175)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:833)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1860)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
"Thread-7562" prio=5 tid=25 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x426ab1b0 self=0x58b6f030
| sysTid=26080 nice=0 sched=0/0 cgrp=apps handle=1488405504
| state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x426ab370> (a java.lang.VMThread) held by tid=25 (Thread-7562)
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:199)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2058)
at com.package.util.VRBlockingHolder.poll(VRBlockingHolder.java:85)
at com.package.util.VRBlockingIndicator.isActive(VRBlockingIndicator.java:42)
at com.package.packagename.VRBackgroundTaskRunner$OneThread.run(VRBackgroundTaskRunner.java:82)
"Thread-7561" prio=5 tid=24 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42a3b5a0 self=0x4177f188
| sysTid=26079 nice=0 sched=0/0 cgrp=apps handle=1488942696
| state=S schedstat=( 0 0 0 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42a3b6e0> (a java.lang.VMThread) held by tid=24 (Thread-7561)
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:199)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2058)
at com.package.util.VRBlockingHolder.poll(VRBlockingHolder.java:85)
at com.package.util.VRBlockingIndicator.isActive(VRBlockingIndicator.java:42)
at com.package.packagename.VRBackgroundTaskRunner$OneThread.run(VRBackgroundTaskRunner.java:82)
"Thread-7514" prio=5 tid=23 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42f6d0b0 self=0x57af4b48
| sysTid=25583 nice=0 sched=0/0 cgrp=apps handle=1471220936
| state=S schedstat=( 0 0 0 ) utm=2825 stm=1344 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42680658> (a java.lang.VMThread) held by tid=23 (Thread-7514)
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:199)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2058)
at com.package.util.VRBlockingHolder.poll(VRBlockingHolder.java:85)
at com.package.util.VRBlockingIndicator.isActive(VRBlockingIndicator.java:42)
at com.package.packagename.android.map.VRMapSurfaceView$VRMapSurfaceViewDrawThread.run(VRMapSurfaceView.java:152)
"Thread-7513" prio=5 tid=21 WAIT
| group="main" sCount=1 dsCount=0 obj=0x42f6cf90 self=0x5190eb28
| sysTid=25582 nice=0 sched=0/0 cgrp=apps handle=1373146856
| state=S schedstat=( 0 0 0 ) utm=0 stm=1 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x421dfbc0> (a java.lang.Object)
at java.lang.Object.wait(Object.java:364)
at com.package.packagename.map.VRMapController.waitForNextLoadRequest(VRMapController.java:233)
at com.package.packagename.map.VRMapImageLoader.run(VRMapImageLoader.java:44)
"Timer-11" prio=5 tid=22 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42209970 self=0x58dc5440
| sysTid=25579 nice=0 sched=0/0 cgrp=apps handle=1494663176
| state=S schedstat=( 0 0 0 ) utm=30 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42209970> (a java.util.Timer$TimerImpl)
at java.lang.Object.wait(Object.java:401)
at java.util.Timer$TimerImpl.run(Timer.java:238)
"Thread-7494" prio=5 tid=20 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42b4fe40 self=0x4179adc8
| sysTid=25563 nice=0 sched=0/0 cgrp=apps handle=1099057424
| state=S schedstat=( 0 0 0 ) utm=235 stm=33 core=1
at java.lang.VMThread.sleep(Native Method)
at java.lang.Thread.sleep(Thread.java:1013)
at java.lang.Thread.sleep(Thread.java:995)
at com.package.packagename.map.VRMapView$LongTasksThread.run(VRMapView.java:2806)
"Thread-7449" prio=5 tid=18 TIMED_WAIT
| group="main" sCount=1 dsCount=0 obj=0x42b4da70 self=0x591612b8
| sysTid=25446 nice=0 sched=0/0 cgrp=apps handle=1494619912
| state=S schedstat=( 0 0 0 ) utm=579 stm=400 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x42b4db70> (a java.lang.VMThread) held by tid=18 (Thread-7449)
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:199)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2058)
at com.package.util.VRBlockingHolder.poll(VRBlockingHolder.java:85)
at com.package.util.VRBlockingIndicator.isActive(VRBlockingIndicator.java:42)
at com.package.packagename.VRBackgroundTaskRunner$OneThread.run(VRBackgroundTaskRunner.java:82)
"Thread-7354" prio=5 tid=19 WAIT
| group="main" sCount=1 dsCount=0 obj=0x421f0330 self=0x51d8c7e0
| sysTid=24637 nice=0 sched=0/0 cgrp=apps handle=1074503688
| state=S schedstat=( 0 0 0 ) utm=24 stm=3 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x421f04a0> (a java.lang.Object)
at java.lang.Object.wait(Object.java:364)
at com.package.packagename.map.VRHeightMapLoadThread.run(VRHeightMapLoadThread.java:113)
"Binder_3" prio=5 tid=17 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x421ecb00 self=0x51d868b0
| sysTid=24493 nice=0 sched=0/0 cgrp=apps handle=1074208152
| state=S schedstat=( 0 0 0 ) utm=139 stm=69 core=1
#00 pc 0001b300 /system/lib/libc.so (__ioctl+8)
#01 pc 0002b91b /system/lib/libc.so (ioctl+14)
#02 pc 0001b539 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+140)
#03 pc 0001bcd7 /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001fae9 /system/lib/libbinder.so
#05 pc 00011a8d /system/lib/libutils.so (android::Thread::_threadLoop(void*)+216)
#06 pc 0004b631 /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+68)
#07 pc 00011581 /system/lib/libutils.so
#08 pc 0000ca58 /system/lib/libc.so (__thread_entry+72)
#09 pc 0000cbd4 /system/lib/libc.so (pthread_create+208)
at dalvik.system.NativeStart.run(Native Method)
"AsyncTask #5" prio=5 tid=16 WAIT
| group="main" sCount=1 dsCount=0 obj=0x421dacb8 self=0x51dd65c8
| sysTid=24481 nice=10 sched=0/0 cgrp=apps/bg_non_interactive handle=1373465112
| state=S schedstat=( 0 0 0 ) utm=3 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x421dae10> (a java.lang.VMThread) held by tid=16 (AsyncTask #5)
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:159)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2019)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1013)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1073)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
"RefQueueWorker@org.apache.http.impl.conn.tsccm.ConnPoolByRoute@4216db88"
守护进程prio = 5 tid = 15 WAIT | group =“main”sCount = 1 dsCount = 0 obj = 0x4216e7e0 self = 0x400b6a18 | sysTid = 24414 nice = 0 sched = 0/0 cgrp = apps handle = 1074723664 | state = S schedstat =(0 0 0)utm = 0 stm = 0在java.lang.Object.wait上的core = 1(Native Method) - 等待<0x421b5820 ...
发出警报后,检查服务是否运行。 如果它正在运行,那么跳过或如果没有,那么做同样的工作,你正在工作。 检查服务代码是否运行:
private boolean isMyServiceRunning(){ActivityManager manager =(ActivityManager)getSystemService(Context.ACTIVITY_SERVICE); for(RunningServiceInfo service:manager.getRunningServices(Integer.MAX_VALUE)){if(MyService.class.getName()。equals(service.service.getClassName())){return true; }} return false; }
可能是,你开始这么多的服务。
我遇到了同样的问题,如果您使用两个线程 ,则会出现问题!:
首先从一个线程运行(例如:Asynctask):
然后尝试从其他线程(例如:UI-Thread)使用dao - >它将永久等待,因为从第一个任务中缺少restoreAutocommit - >这会导致ANR!
解决方法是:添加一个终止到restoreAutocommit
例:
boolean prev = entityDao.disableAutoCommit();
try
{
entityDao.disableAutoCommit();
storeData(data);// if an Exception occurs -> finally is also called
}
finally
{
entityDao.restoreAutocommit(prev);
}
链接地址: http://www.djcxy.com/p/61979.html