【我的Android进阶之旅】解决sqlcipher库:java.lang.IllegalStateException: get field slot from row 0 col 0 failed.
一、背景
最近维护公司的大数据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://stackoverflow.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://stackoverflow.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如果觉得本文对您有所帮助,欢迎您扫码下图所示的支付宝和微信支付二维码对本文进行随意打赏。您的支持将鼓励我继续创作!
【我的Android进阶之旅】解决sqlcipher库:java.lang.IllegalStateException: get field slot from row 0 col 0 failed.的更多相关文章
- 我的Android进阶之旅------>解决Jackson等第三方转换Json的开发包在开启混淆后转换的实体类数据都是null的bug
1.错误描述 今天测试人员提了一个bug,说使用我们的app出现了闪退的bug,后来通过debug断点调试,发现我们的app转换服务器发送过来的json数据后,都是为null.而之前已经提测快一个月的 ...
- 我的Android进阶之旅------>解决错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
#1.错误描述 今天,想实现Activity不显示标题栏的效果,在项目的AndroidManifest.xml文件,对相应的Activity添加属性 android:theme="@andr ...
- android TimerTask 的简单应用,以及java.lang.IllegalStateException: TimerTask is scheduled already错误的解决方法【转】
Android应用开发中常常会用到定时器,不可避免的需要用到 TimerTask 定时器任务这个类下面简单的一个示例演示了如何使用TimerTask这个示例演示了3秒未有触屏事件发生则锁屏(只是设置下 ...
- Android开发中使用数据库时出现java.lang.IllegalStateException: Cannot perform this operation because the connection pool has been closed.
最近在开发一个 App 的时候用到了数据库,可是在使用数据库的时候就出现了一些问题,在我查询表中的一些信息时出现了一下问题: Caused by: java.lang.IllegalStateExce ...
- 我的Android进阶之旅------>解决DownloadManager报错java.lang.SecurityException: Invalid value for visibility: 2
1.问题描述 今天使用Android系统的DownloadManager进行下载操作时,爆了如下所示的错误: java.lang.RuntimeException: Unable to start s ...
- 我的Android进阶之旅------>解决Jackson、Gson解析Json数据时,Json数据中的Key为Java关键字时解析为null的问题
1.问题描述 首先,需要解析的Json数据类似于下面的格式,但是包含了Java关键字abstract: { ret: 0, msg: "normal return.", news: ...
- 我的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 ...
- 我的Android进阶之旅------>解决错误: java.util.regex.PatternSyntaxException: Incorrect Unicode property
1.错误描述 今天使用正则表达式验证密码的时候,报了错误 java.util.regex.PatternSyntaxException: Incorrect Unicode property near ...
- 我的Android进阶之旅------>解决Error: specified for property 'mergedManifest' does not exist.
错误描述 刚运行从Github上面下载而来的代码时,爆了如下所示的bug,错误描述如下所示: Error:A problem was found with the configuration of t ...
随机推荐
- VC++ : GetIDsOfNames 调用失败,获取的dispid为-1
今天调试自己的程序,需要调用一个COM组件中的方法,利用GetIDsOfNames获取调用函数对象的DISPID. GetIDsOfNames: 把COM接口的方法名字和参数(可选)映射成一组DISP ...
- hdu 4849 最短路 西安邀请赛 Wow! Such City!
http://acm.hdu.edu.cn/showproblem.php?pid=4849 会有非常多奇怪的Wa的题.当初在西安就不知道为什么wa,昨晚做了,由于一些Sb错误也wa了非常久.这会儿怎 ...
- js实现卡号每四位空格分隔
window.onload =function() { document.getElementById("input_num").oninput =function() { })( ...
- Python Scrapy 自动爬虫注意细节(2)
一.自动爬虫的创建,需要指定模版 如: scrapy genspider -t crawl stockinfo quote.eastmoney.com crawl : 爬虫模版 stockinfo : ...
- ftplib模块【python】
转自:http://www.cnblogs.com/kaituorensheng/p/4480512.html 函数释义 Python中默认安装的ftplib模块定义了FTP类,其中函数有限,可用来实 ...
- jquery 获取当前时间加180天
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- 一个php日志类
<?php //author:lixiuran class Log { public static function writeLog($string) { $string = date('H: ...
- (二)微信小程序的三种传值方式
1.全局变量 app.js里 App({ //全局变量 globalData: { userInfo: null, host: 'http://localhost:8080/data.json' } ...
- php第一例
参考 例子 https://www.cnblogs.com/chinajins/p/5622342.html 配置多个网站 https://blog.csdn.net/win7system/artic ...
- jQuery的一些小技巧()
1.判断某元素上是否绑定了某种类型的事件 var $events = $("#foo").data("events"); if( $events &&a ...