ANR与SQLite交互时

时间:2018-03-12 09:02:46

标签: java android sqlite android-anr-dialog

有时在与SQLite交互时获取ANR。 不是崩溃,而是ANR

崩溃日志始终相同。即使SQL请求在UI线程上执行,也有1-2个快速请求,没有循环等。

找不到任何类似的ANR。看起来它正在等待本机代码中的互斥锁。也许它甚至不是SQLite因为这一行。

  

Java_android_util_Log_isLoggable__Ljava_lang_String_2I + 116)     在android.util.Log.isLoggable(本机方法)

任何挖掘方向?

ANR追踪。

DALVIK THREADS (22):
"main" prio=5 tid=1 Native
  | group="main" sCount=1 dsCount=0 obj=0x72b6a700 self=0xb483d500
  | sysTid=1459 nice=0 cgrp=default sched=0/0 handle=0xb6f48bec
  | state=S schedstat=( 38819958947 298321576 2674 ) utm=2603 stm=1278 core=2 HZ=100
  | stack=0xbe11b000-0xbe11d000 stackSize=8MB
  | held mutexes=
  native: #00 pc 000133bc  /system/lib/libc.so (syscall+28)
  native: #01 pc 000a8be3  /system/lib/libart.so (art::ConditionVariable::Wait(art::Thread*)+82)
  native: #02 pc 0027bb5d  /system/lib/libart.so (art::GoToRunnable(art::Thread*)+756)
  native: #03 pc 000872b9  /system/lib/libart.so (art::JniMethodEnd(unsigned int, art::Thread*)+8)
  native: #04 pc 00086da1  /data/dalvik-cache/arm/system@framework@boot.oat (Java_android_util_Log_isLoggable__Ljava_lang_String_2I+116)
  at android.util.Log.isLoggable(Native method)
  at android.database.CursorWindow.recordNewWindow(CursorWindow.java:725)
  - locked <@addr=0x6f920340> (a android.util.LongSparseArray)
  at android.database.CursorWindow.<init>(CursorWindow.java:112)
  at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
  at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:139)
  at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)
  at com.xxx.xxx.xxx.getChildren(xxx.java:1122)
  at com.xxx.xxx.xxx.getFolderFromDatabase(xxx.java:1109)
  at com.xxx.xxx.xxx.getFolder(xxx.java:868)
  at com.xxx.xxx.yyy.getFolder(StationFolder.java:644)
  at com.xxx.xxx.yyy.getParent(StationFolder.java:251)
  at com.xxx.xxx.utils.CategoryItemUtils.getPathByRootItem(CategoryItemUtils.java:244)
  at com.xxx.xxx.ui.adapter.UniversalListAdapter.loadData(UniversalListAdapter.java:237)
  at com.xxx.xxx.ui.fragment.UniversalListFragment$LoadCategoryDataAsync.onPostExecute(UniversalListFragment.java:761)
  at android.os.AsyncTask.finish(AsyncTask.java:636)
  at android.os.AsyncTask.access$500(AsyncTask.java:177)
  at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
  at android.os.Handler.dispatchMessage(Handler.java:102)
  at android.os.Looper.loop(Looper.java:135)
  at android.app.ActivityThread.main(ActivityThread.java:5258)
  at java.lang.reflect.Method.invoke!(Native method)
  at java.lang.reflect.Method.invoke(Method.java:372)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:940)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:735)

1 个答案:

答案 0 :(得分:0)

将您的SQL操作移至后台线程