一、背景

最近维护公司的大数据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,百度答案。查询到的有参考一样的链接如下所示:

其中有一段话,说的是

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的限制。

五、参考链接


作者:欧阳鹏 欢迎转载,与人分享是进步的源泉!

转载请保留原文地址:http://blog.csdn.net/ouyang_peng/article/details/79228417

如果觉得本文对您有所帮助,欢迎您扫码下图所示的支付宝和微信支付二维码对本文进行随意打赏。您的支持将鼓励我继续创作!

【我的Android进阶之旅】解决sqlcipher库:java.lang.IllegalStateException: get field slot from row 0 col 0 failed.的更多相关文章

  1. 我的Android进阶之旅------>解决Jackson等第三方转换Json的开发包在开启混淆后转换的实体类数据都是null的bug

    1.错误描述 今天测试人员提了一个bug,说使用我们的app出现了闪退的bug,后来通过debug断点调试,发现我们的app转换服务器发送过来的json数据后,都是为null.而之前已经提测快一个月的 ...

  2. 我的Android进阶之旅------>解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.

    #1.错误描述 今天,想实现Activity不显示标题栏的效果,在项目的AndroidManifest.xml文件,对相应的Activity添加属性 android:theme="@andr ...

  3. android TimerTask 的简单应用,以及java.lang.IllegalStateException: TimerTask is scheduled already错误的解决方法【转】

    Android应用开发中常常会用到定时器,不可避免的需要用到 TimerTask 定时器任务这个类下面简单的一个示例演示了如何使用TimerTask这个示例演示了3秒未有触屏事件发生则锁屏(只是设置下 ...

  4. Android开发中使用数据库时出现java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.

    最近在开发一个 App 的时候用到了数据库,可是在使用数据库的时候就出现了一些问题,在我查询表中的一些信息时出现了一下问题: Caused by: java.lang.IllegalStateExce ...

  5. 我的Android进阶之旅------>解决DownloadManager报错java.lang.SecurityException: Invalid value for visibility: 2

    1.问题描述 今天使用Android系统的DownloadManager进行下载操作时,爆了如下所示的错误: java.lang.RuntimeException: Unable to start s ...

  6. 我的Android进阶之旅------>解决Jackson、Gson解析Json数据时,Json数据中的Key为Java关键字时解析为null的问题

    1.问题描述 首先,需要解析的Json数据类似于下面的格式,但是包含了Java关键字abstract: { ret: 0, msg: "normal return.", news: ...

  7. 我的Android进阶之旅------>解决AES加密报错:java.security.InvalidKeyException: Unsupported key size: 18 bytes

    1.错误描述 今天使用AES进行加密时候,报错如下所示: 04-21 11:08:18.087 27501-27501/com.xtc.watch E/AESUtil.decryptAES:55: j ...

  8. 我的Android进阶之旅------>解决错误: java.util.regex.PatternSyntaxException: Incorrect Unicode property

    1.错误描述 今天使用正则表达式验证密码的时候,报了错误 java.util.regex.PatternSyntaxException: Incorrect Unicode property near ...

  9. 我的Android进阶之旅------>解决Error: specified for property 'mergedManifest' does not exist.

    错误描述 刚运行从Github上面下载而来的代码时,爆了如下所示的bug,错误描述如下所示: Error:A problem was found with the configuration of t ...

随机推荐

  1. 【Java面试题】36 List、Map、Set三个接口,存取元素时,各有什么特点?

    List与Set都是单列元素的集合,它们有一个功共同的父接口Collection. Set里面不允许有重复的元素, 存元素:add方法有一个boolean的返回值,当集合中没有某个元素,此时add方法 ...

  2. YII2中的Html助手和Request组件

    Html助手 1 .在@app\views\test的index.php中: <?php //引入命名空间 use yii\helpers\Html; ?> <?php //[一]表 ...

  3. 搜集的一些酷炫的金属色 ,RGB值 和大家分享一下

    开发iOS程序过程中会使用到RGB,要注意每个RGB值都要除以 255.0 ,注意: ' .0 ' 不能省!! 一下是本人搜集的一些酷炫金属色的RGB值:   黄金 242,192,86 石墨 87, ...

  4. Oracle 11g 的bug?: aix 上,expdp 11.2.0.1 导出,impdp 11.2.0.3 导入,Interval 分区的 【Interval】 分区属性成了【N】

    如题: Oracle 11g 的bug?: aix 上,expdp 11.2.0.1 导出,impdp 11.2.0.3 导入,Interval 分区的 [Interval] 分区属性成了[N] 谨记 ...

  5. 如何在浏览器控制台(console)里输出彩色样式调试信息

    console.log(XX,XX,XX) log 的第一个参数声明第二.第三个参数的作用,第二个参数就是样式,第三个参数是要输出的字符串 console.log("%c%s", ...

  6. laravel 查询构建器(连贯操作)

    注:laravel 查询返回行的都是 php 的 stdClass 对象实例,不是数组!!!! 1)查询多行(get) DB::table('table_name')->get(); 带偏移和限 ...

  7. linux解压和压缩

    1.压缩命令: 命令格式:tar  -zcvf   压缩文件名.tar.gz   被压缩文件名 可先切换到当前目录下.压缩文件名和被压缩文件名都可加入路径. 2.解压缩命令: 命令格式:tar  -z ...

  8. Unity和虚幻的比较

    很多人从Unity开始转向虚幻4了,我目前则相反,从研究使用虚幻4,回到了Unity 5上. 前端总结的Unity和Unreal 4的一些优缺点,自己做的对比图.就先放这里了. 其实,作为引擎,各有优 ...

  9. 第三篇:基于K-近邻分类算法的手写识别系统

    前言 本文将继续讲解K-近邻算法的项目实例 - 手写识别系统. 该系统在获取用户的手写输入后,判断用户写的是什么. 为了突出核心,简化细节,本示例系统中的输入为32x32矩阵,分类结果也均为数字.但对 ...

  10. iGson

    头文件 #import <Foundation/Foundation.h> #import <objc/runtime.h> #import "NSString+Ut ...