一、背景
最近维护公司的大数据SDK,在大数据SDK里面加入了ANR的监控功能,并将ANR的相关信息通过大数据埋点的方式记录到了数据库中,然后大数据上报的时候上报到大数据平台,这样就可以实现ANR性能的监控功能。
但是,最近看友盟的大数据平台错误上, 有一个是调用大数据SDK上报时,查询数据库出现的异常,异常错误信息如下所示:
java.lang.IllegalStateException: get field slot from row 0 col 0 failed
at net.sqlcipher.CursorWindow.getString_native(Native Method)
at net.sqlcipher.CursorWindow.getString(CursorWindow.java:385)
at net.sqlcipher.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
at android.database.CursorWrapper.getString(CursorWrapper.java:137)
at com.j256.ormlite.sqlcipher.android.AndroidDatabaseResults.getString(AndroidDatabaseResults.java:135)
at com.j256.ormlite.field.types.StringType.resultToSqlArg(StringType.java:39)
at com.j256.ormlite.field.BaseFieldConverter.resultToJava(BaseFieldConverter.java:24)
at com.j256.ormlite.field.FieldType.resultToJava(FieldType.java:819)
at com.j256.ormlite.stmt.mapped.BaseMappedQuery.mapRow(BaseMappedQuery.java:60)
at com.j256.ormlite.stmt.SelectIterator.getCurrent(SelectIterator.java:270)
at com.j256.ormlite.stmt.SelectIterator.nextThrow(SelectIterator.java:161)
at com.j256.ormlite.stmt.StatementExecutor.query(StatementExecutor.java:202)
at com.j256.ormlite.dao.BaseDaoImpl.query(BaseDaoImpl.java:265)
at com.j256.ormlite.stmt.QueryBuilder.query(QueryBuilder.java:361)
at com.xtc.data.database.OrmLiteDao.queryForPagesByOrder(OrmLiteDao.java:487)
at com.xtc.bigdata.report.db.ReportDao.deleteByStatus(ReportDao.java:88)
at com.xtc.bigdata.report.upload.ReportIntentService$1.onSuccess(ReportIntentService.java:84)
at com.xtc.bigdata.report.upload.task.ReportTask$1.onResponse(ReportTask.java:121)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:126)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:760)
这个异常一下子就出现了 348次,影响了6个用户,有一款机型出现了316次, 里面将整个app的整体奔溃率拉高了。简直要命啊!
二、分析问题
猜测一、大数据SDK版本没更新
开始我以为是大数据SDK更新删除字段,增加字段后,没有升级大数据的数据库版本。但是之前发布的APP引用的大数据SDK的数据库版本为3,而刚刚发布的APP的大数据SDK的数据库版本为4,整体上数据库升级了,应该是没有问题的。
猜测二 、数据库查询的单条记录超过1MB
一开始,完全找不到原因,只能靠各种猜测,各种google,百度答案。查询到的有参考一样的链接如下所示:
- https://*.com/questions/5406429/cursor-size-limit-in-android-sqlitedatabase
- https://github.com/sqlcipher/android-database-sqlcipher/issues/341#issuecomment-310289295
其中有一段话,说的是
There’s a limit of 1MB on internal assets due to dynamic decompression; the 1MB limit also seems to apply to Cursor blobs but this doesn’t seem to be documented anywhere.
Generally you should avoid blobs in SQLite as they perform poorly; instead save the blob data as a file and store the location of the file in your DB.
1、分析抓取的日志
通过抓取到的日志信息来看,因为这个异常是发生在捕获到ANRException之后,触发了大数据SDK上报的操作而导致异常的。所以初步怀疑是ANR的堆栈信息太多导致查询数据库时候奔溃了。
2、一次性查询出来的多条信息超过1Mb是否会奔溃?
一开始我和另外一个同事进行压测,将拉取到的日志ANR异常日志的stackInfo循环500次插入数据库然后每200条取出来一次查询。这样一次性查询出来的多条信息查过了1Mb,但是完全没有奔溃一切正常。因此排除了一次性查询出来的多条信息超过1Mb是否会奔溃这个点。
3、一次性查询出来的单条信息超过1Mb是否会奔溃?
后来我又去测了一下,如果一条数据量超过1Mb会怎么样?测试结果是这个异常果断出现了。
测试方法如下:
点击某个按钮,执行下面的startTest() 方法,手动埋上一个ANRException,单挑的堆栈信息很大,测试代码是临时测试的。
private void startTest() {
new Thread() {
@Override
public void run() {
StringBuffer stack = new StringBuffer("[W][2018-01-30 +8.0 10:24:58.596][14396, 274][:][com.xtc.bigdata.monitor.anr.ANRMonitor, dumpBlockInfo, 48][stackTraceInfo:01-30 10:23:12.153\n" +
"com.xtc.watch.view.remoteadd.activity.MatchContactActivity$9.onKey(MatchContactActivity.java:503)\n" +
"android.view.View.dispatchKeyEvent(View.java:8416)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5899)\n" +
"android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3417)\n" +
"android.os.Handler.dispatchMessage(Handler.java:102)\n" +
"android.os.Looper.loop(Looper.java:135)\n" +
"android.app.ActivityThread.main(ActivityThread.java:5418)\n" +
"java.lang.reflect.Method.invoke(Native Method)\n" +
"java.lang.reflect.Method.invoke(Method.java:372)\n" +
"com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)\n" +
"com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)\n" +
"\n" +
"01-30 10:23:13.233\n" +
"com.xtc.watch.view.remoteadd.activity.MatchContactActivity$9.onKey(MatchContactActivity.java:503)\n" +
"android.view.View.dispatchKeyEvent(View.java:8416)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5899)\n" +
"android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3417)\n" +
"android.os.Handler.dispatchMessage(Handler.java:102)\n" +
"android.os.Looper.loop(Looper.java:135)\n" +
"android.app.ActivityThread.main(ActivityThread.java:5418)\n" +
"java.lang.reflect.Method.invoke(Native Method)\n" +
"java.lang.reflect.Method.invoke(Method.java:372)\n" +
"com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)\n" +
"com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)\n" +
"\n" +
"01-30 10:23:14.312\n" +
"com.xtc.watch.view.remoteadd.activity.MatchContactActivity$9.onKey(MatchContactActivity.java:503)\n" +
"android.view.View.dispatchKeyEvent(View.java:8416)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5899)\n" +
"android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3417)\n" +
"android.os.Handler.dispatchMessage(Handler.java:102)\n" +
"android.os.Looper.loop(Looper.java:135)\n" +
"android.app.ActivityThread.main(ActivityThread.java:5418)\n" +
"java.lang.reflect.Method.invoke(Native Method)\n" +
"java.lang.reflect.Method.invoke(Method.java:372)\n" +
"com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)\n" +
"com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)\n" +
"\n" +
"01-30 10:23:15.392\n" +
"com.xtc.watch.view.remoteadd.activity.MatchContactActivity$9.onKey(MatchContactActivity.java:503)\n" +
"android.view.View.dispatchKeyEvent(View.java:8416)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5899)\n" +
"android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3417)\n" +
"android.os.Handler.dispatchMessage(Handler.java:102)\n" +
"android.os.Looper.loop(Looper.java:135)\n" +
"android.app.ActivityThread.main(ActivityThread.java:5418)\n" +
"java.lang.reflect.Method.invoke(Native Method)\n" +
"java.lang.reflect.Method.invoke(Method.java:372)\n" +
"com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)\n" +
"com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)\n" +
"\n" +
"01-30 10:23:16.459\n" +
"com.xtc.watch.view.remoteadd.activity.MatchContactActivity$9.onKey(MatchContactActivity.java:503)\n" +
"android.view.View.dispatchKeyEvent(View.java:8416)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5899)\n" +
"android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3417)\n" +
"android.os.Handler.dispatchMessage(Handler.java:102)\n" +
"android.os.Looper.loop(Looper.java:135)\n" +
"android.app.ActivityThread.main(ActivityThread.java:5418)\n" +
"java.lang.reflect.Method.invoke(Native Method)\n" +
"java.lang.reflect.Method.invoke(Method.java:372)\n" +
"com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)\n" +
"com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)\n" +
"\n" +
"01-30 10:23:17.526\n" +
"com.xtc.widget.phone.view.IconCenterEditText.onFocusChange(IconCenterEditText.java:58)\n" +
"android.view.View.onFocusChanged(View.java:5216)\n" +
"android.widget.TextView.onFocusChanged(TextView.java:8032)\n" +
"android.view.View.clearFocusInternal(View.java:5099)\n" +
"android.view.View.unFocus(View.java:5132)\n" +
"android.view.ViewGroup.unFocus(ViewGroup.java:864)\n" +
"android.view.ViewGroup.unFocus(ViewGroup.java:864)\n" +
"android.view.ViewGroup.unFocus(ViewGroup.java:864)\n" +
"android.view.ViewGroup.unFocus(ViewGroup.java:864)\n" +
"android.view.ViewGroup.requestChildFocus(ViewGroup.java:665)\n" +
"android.view.ViewGroup.requestChildFocus(ViewGroup.java:671)\n" +
"android.view.View.handleFocusGainInternal(View.java:4965)\n" +
"android.view.ViewGroup.handleFocusGainInternal(ViewGroup.java:645)\n" +
"android.view.View.requestFocusNoSearch(View.java:7688)\n" +
"android.view.View.requestFocus(View.java:7667)\n" +
"android.view.ViewGroup.requestFocus(ViewGroup.java:2629)\n" +
"android.view.View.requestFocus(View.java:7634)\n" +
"android.widget.TextView.onKeyUp(TextView.java:6022)\n" +
"android.view.KeyEvent.dispatch(KeyEvent.java:2701)\n" +
"android.view.View.dispatchKeyEvent(View.java:8426)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5899)\n" +
"android.view.ViewRootI\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"\n" +
"01-30 10:23:13.233\n" +
"com.xtc.watch.view.remoteadd.activity.MatchContactActivity$9.onKey(MatchContactActivity.java:503)\n" +
"android.view.View.dispatchKeyEvent(View.java:8416)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5899)\n" +
"android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3417)\n" +
"android.os.Handler.dispatchMessage(Handler.java:102)\n" +
"android.os.Looper.loop(Looper.java:135)\n" +
"android.app.ActivityThread.main(ActivityThread.java:5418)\n" +
"java.lang.reflect.Method.invoke(Native Method)\n" +
"java.lang.reflect.Method.invoke(Method.java:372)\n" +
"com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)\n" +
"com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)\n" +
"\n" +
"01-30 10:23:14.312\n" +
"com.xtc.watch.view.remoteadd.activity.MatchContactActivity$9.onKey(MatchContactActivity.java:503)\n" +
"android.view.View.dispatchKeyEvent(View.java:8416)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5899)\n" +
"android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3417)\n" +
"android.os.Handler.dispatchMessage(Handler.java:102)\n" +
"android.os.Looper.loop(Looper.java:135)\n" +
"android.app.ActivityThread.main(ActivityThread.java:5418)\n" +
"java.lang.reflect.Method.invoke(Native Method)\n" +
"java.lang.reflect.Method.invoke(Method.java:372)\n" +
"com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)\n" +
"com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)\n" +
"\n" +
"01-30 10:23:15.392\n" +
"com.xtc.watch.view.remoteadd.activity.MatchContactActivity$9.onKey(MatchContactActivity.java:503)\n" +
"android.view.View.dispatchKeyEvent(View.java:8416)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5899)\n" +
"android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3417)\n" +
"android.os.Handler.dispatchMessage(Handler.java:102)\n" +
"android.os.Looper.loop(Looper.java:135)\n" +
"android.app.ActivityThread.main(ActivityThread.java:5418)\n" +
"java.lang.reflect.Method.invoke(Native Method)\n" +
"java.lang.reflect.Method.invoke(Method.java:372)\n" +
"com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)\n" +
"com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)\n" +
"\n" +
"01-30 10:23:16.459\n" +
"com.xtc.watch.view.remoteadd.activity.MatchContactActivity$9.onKey(MatchContactActivity.java:503)\n" +
"android.view.View.dispatchKeyEvent(View.java:8416)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5899)\n" +
"android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3417)\n" +
"android.os.Handler.dispatchMessage(Handler.java:102)\n" +
"android.os.Looper.loop(Looper.java:135)\n" +
"android.app.ActivityThread.main(ActivityThread.java:5418)\n" +
"java.lang.reflect.Method.invoke(Native Method)\n" +
"java.lang.reflect.Method.invoke(Method.java:372)\n" +
"com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1037)\n" +
"com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)\n" +
"\n" +
"01-30 10:23:17.526\n" +
"com.xtc.widget.phone.view.IconCenterEditText.onFocusChange(IconCenterEditText.java:58)\n" +
"android.view.View.onFocusChanged(View.java:5216)\n" +
"android.widget.TextView.onFocusChanged(TextView.java:8032)\n" +
"android.view.View.clearFocusInternal(View.java:5099)\n" +
"android.view.View.unFocus(View.java:5132)\n" +
"android.view.ViewGroup.unFocus(ViewGroup.java:864)\n" +
"android.view.ViewGroup.unFocus(ViewGroup.java:864)\n" +
"android.view.ViewGroup.unFocus(ViewGroup.java:864)\n" +
"android.view.ViewGroup.unFocus(ViewGroup.java:864)\n" +
"android.view.ViewGroup.requestChildFocus(ViewGroup.java:665)\n" +
"android.view.ViewGroup.requestChildFocus(ViewGroup.java:671)\n" +
"android.view.View.handleFocusGainInternal(View.java:4965)\n" +
"android.view.ViewGroup.handleFocusGainInternal(ViewGroup.java:645)\n" +
"android.view.View.requestFocusNoSearch(View.java:7688)\n" +
"android.view.View.requestFocus(View.java:7667)\n" +
"android.view.ViewGroup.requestFocus(ViewGroup.java:2629)\n" +
"android.view.View.requestFocus(View.java:7634)\n" +
"android.widget.TextView.onKeyUp(TextView.java:6022)\n" +
"android.view.KeyEvent.dispatch(KeyEvent.java:2701)\n" +
"android.view.View.dispatchKeyEvent(View.java:8426)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1507)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchKeyEvent(PhoneWindow.java:2479)\n" +
"com.android.internal.policy.impl.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1770)\n" +
"android.app.Activity.dispatchKeyEvent(Activity.java:2764)\n" +
"com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:2372)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4128)\n" +
"android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4086)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3776)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3833)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3687)\n" +
"android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3647)\n" +
"android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3655)\n" +
"android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3621)\n" +
"android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5965)\n" +
"android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5939)\n" +
"android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.");
for (int i =0 ;i <=5;i++){
stack.append(stack);
}
while (true) {
for (int i = 0;i < 1;i++) {
String stackString = new String(stack);
ANRException anrException = new ANRException(stackString);
ExceptionEvent exceptionEvent = new ExceptionEvent();
exceptionEvent.functionName = "ANR-ERROR-" + Constants.HOST_APP_ID;
exceptionEvent.reason = anrException.toString();
exceptionEvent.stack = stackString;
CollectionManager.getInstance().exceptionEvent(exceptionEvent);
}
try {
Thread.sleep(300000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}.start();
}
然后果断的出现了异常,异常如下所示:
通过上面的测试,发现了这个crash的根本原因就是,单挑数据库的记录过大,导致查询的时候出现奔溃。
三、处理方法
3.1 将大数据SDK的ANR监控暂时屏蔽掉
,现有的ANR监控的堆栈信息太多,容易出问题。而且在我们进行压测的过程中,发现及时单条记录不超过1mb,但是多条记录过大的时候,http上报大数据的时候,http的请求的body过大也会导致请求失败,因此暂时将ANR监控的功能屏蔽掉。
3.2 对调用OrmLiteDao封装类的相关代码处加上 try/catch 处理
因为OrmLiteDao封装类里面,只捕获了SQL相关的异常,没有捕获其他类型的异常,所以出现的时候就会奔溃。
因为OrmLiteDao的封装类,我们在封装的时候只catch了sql操作习惯的异常,因此暂时在调用数据库操作的时候,在调用的地方加上 try/catch 捕获住刚才的IllegalStateException异常。
3.3 对 android-database-sqlcipher 进行升级
在 android-database-sqlcipher 这个项目中,
有人提了相同的Issue,链接如下所示:
https://github.com/sqlcipher/android-database-sqlcipher/issues/341#issuecomment-310289295 ,
通过查看Issue的描述,发现和我们的这个crash类似。
然后我们将 net.zetetic:android-database-sqlcipher 库进行了升级。
一开始我们项目引用的版本为: net.zetetic:android-database-sqlcipher:3.5.4
单条数据太大的时候,就会奔溃
升级为 net.zetetic:android-database-sqlcipher:3.5.9
升级完成之后,重新编译APP,然后重新进行压测,发现这个crash不存在了。
四、总结
- 不要在数据库中的单条数据插入太多的数据。
- 通过升级net.zetetic:android-database-sqlcipher版本到3.5.9可以修复这个1MB的限制。
五、参考链接
- https://*.com/questions/5406429/cursor-size-limit-in-android-sqlitedatabase
- https://github.com/sqlcipher/android-database-sqlcipher/issues/341#issuecomment-310289295
- https://github.com/sqlcipher/android-database-sqlcipher
作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!
转载请保留原文地址:http://blog.csdn.net/ouyang_peng/article/details/79228417如果觉得本文对您有所帮助,欢迎您扫码下图所示的支付宝和微信支付二维码对本文进行随意打赏。您的支持将鼓励我继续创作!