Android Room数据库异常: Room cannot verify the data integrity.

2024-01-31 13:12

本文主要是介绍Android Room数据库异常: Room cannot verify the data integrity.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

文章目录

  • 一、前言
  • 二、错误信息如下
  • 三、参考链接

一、前言

在Room数据库结构变动的情况下,如果没有进行Room数据库升级迁移,则会报错Room cannot verify the data integrity.。在实际开发过程中,数据库结构会经常变化,直到发版。一般来说卸载即可重新安装,但是有时候即使卸载了再安装依然会出现这个错误。这时候通常重启设备再重新安装即可,然而
再后面即使数据库没有更改多次安装还是有概率出现,一旦出现,只能重启。查阅多种资料,最终发现通过禁用备份功能可以解决该问题。猜测是备份功能会自动把之前旧的数据库版本更新下来然后与当前新版本数据库产生了冲突

<applicationandroid:allowBackup="false"tools:replace="android:allowBackup">

二、错误信息如下

01-29 11:05:00.595 17133 17133 E AndroidRuntime: FATAL EXCEPTION: main
01-29 11:05:00.595 17133 17133 E AndroidRuntime: java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number.
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at androidx.room.RoomOpenHelper.checkIdentity(RoomOpenHelper.java:55)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.java:4)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.java:11)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:447)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:332)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:5)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:5)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:3)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:1)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invokeSuspend(Merge.kt:49)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(Merge.kt:2)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.flow.FlowKt__MergeKt$mapLatest$1.invoke(Merge.kt:1)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invokeSuspend(Merge.kt:35)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Merge.kt:2)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1$2.invoke(Merge.kt:1)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:23)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.f.c(Unknown Source:35)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.flow.internal.ChannelFlowTransformLatest$flowCollect$3$1.emit(Merge.kt:109)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.flow.p1.m(SharedFlow.kt:200)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(SharedFlow.kt:13)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:9)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.o0.run(DispatchedTask.kt:124)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.internal.g$a.run(LimitedDispatcher.kt:4)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at a8.i.run(Tasks.kt:3)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	at kotlinx.coroutines.scheduling.CoroutineScheduler$b.run(CoroutineScheduler.kt:101)
01-29 11:05:00.595 17133 17133 E AndroidRuntime: 	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [z1{Cancelling}@d556480, Dispatchers.Main]

三、参考链接

  1. 该链接记录了Room数据库的自身漏洞
    https://issuetracker.google.com/issues/221101259
  2. 该链接记录了Room数据库的自身漏洞
    https://github.com/android/codelab-android-workmanager/issues/283
  3. 该链接记录了一些解决room数据库版本冲突的方案
    https://copyprogramming.com/howto/room-cannot-verify-the-data-integrity-in-android
  4. 解决:room无论如何怎么修改数据库版本都报错java.lang.IllegalStateException: Room cannot verify the data integrity
    https://blog.csdn.net/qq_41888672/article/details/127162613

这篇关于Android Room数据库异常: Room cannot verify the data integrity.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/663874

相关文章

SpringBoot使用Jasypt对YML文件配置内容加密的方法(数据库密码加密)

《SpringBoot使用Jasypt对YML文件配置内容加密的方法(数据库密码加密)》本文介绍了如何在SpringBoot项目中使用Jasypt对application.yml文件中的敏感信息(如数... 目录SpringBoot使用Jasypt对YML文件配置内容进行加密(例:数据库密码加密)前言一、J

解决java.lang.NullPointerException问题(空指针异常)

《解决java.lang.NullPointerException问题(空指针异常)》本文详细介绍了Java中的NullPointerException异常及其常见原因,包括对象引用为null、数组元... 目录Java.lang.NullPointerException(空指针异常)NullPointer

Android开发中gradle下载缓慢的问题级解决方法

《Android开发中gradle下载缓慢的问题级解决方法》本文介绍了解决Android开发中Gradle下载缓慢问题的几种方法,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、网络环境优化二、Gradle版本与配置优化三、其他优化措施针对android开发中Gradle下载缓慢的问

Python调用Orator ORM进行数据库操作

《Python调用OratorORM进行数据库操作》OratorORM是一个功能丰富且灵活的PythonORM库,旨在简化数据库操作,它支持多种数据库并提供了简洁且直观的API,下面我们就... 目录Orator ORM 主要特点安装使用示例总结Orator ORM 是一个功能丰富且灵活的 python O

Android 悬浮窗开发示例((动态权限请求 | 前台服务和通知 | 悬浮窗创建 )

《Android悬浮窗开发示例((动态权限请求|前台服务和通知|悬浮窗创建)》本文介绍了Android悬浮窗的实现效果,包括动态权限请求、前台服务和通知的使用,悬浮窗权限需要动态申请并引导... 目录一、悬浮窗 动态权限请求1、动态请求权限2、悬浮窗权限说明3、检查动态权限4、申请动态权限5、权限设置完毕后

使用 sql-research-assistant进行 SQL 数据库研究的实战指南(代码实现演示)

《使用sql-research-assistant进行SQL数据库研究的实战指南(代码实现演示)》本文介绍了sql-research-assistant工具,该工具基于LangChain框架,集... 目录技术背景介绍核心原理解析代码实现演示安装和配置项目集成LangSmith 配置(可选)启动服务应用场景

Android里面的Service种类以及启动方式

《Android里面的Service种类以及启动方式》Android中的Service分为前台服务和后台服务,前台服务需要亮身份牌并显示通知,后台服务则有启动方式选择,包括startService和b... 目录一句话总结:一、Service 的两种类型:1. 前台服务(必须亮身份牌)2. 后台服务(偷偷干

使用Navicat工具比对两个数据库所有表结构的差异案例详解

《使用Navicat工具比对两个数据库所有表结构的差异案例详解》:本文主要介绍如何使用Navicat工具对比两个数据库test_old和test_new,并生成相应的DDLSQL语句,以便将te... 目录概要案例一、如图两个数据库test_old和test_new进行比较:二、开始比较总结概要公司存在多

MySQL数据库函数之JSON_EXTRACT示例代码

《MySQL数据库函数之JSON_EXTRACT示例代码》:本文主要介绍MySQL数据库函数之JSON_EXTRACT的相关资料,JSON_EXTRACT()函数用于从JSON文档中提取值,支持对... 目录前言基本语法路径表达式示例示例 1: 提取简单值示例 2: 提取嵌套值示例 3: 提取数组中的值注意

查询SQL Server数据库服务器IP地址的多种有效方法

《查询SQLServer数据库服务器IP地址的多种有效方法》作为数据库管理员或开发人员,了解如何查询SQLServer数据库服务器的IP地址是一项重要技能,本文将介绍几种简单而有效的方法,帮助你轻松... 目录使用T-SQL查询方法1:使用系统函数方法2:使用系统视图使用SQL Server Configu