You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决RxDB Premium与Expo React Native SQLite兼容问题?

RxDB Premium SQLite插件在Expo Android上的兼容问题解决办法

持有RxDB Premium授权,使用rxdb-premium/plugins/storage-sqlite插件时,在Expo React Native的Android设备上无法正常工作。原因是Expo内置的SQLite版本为3.32.2,而该插件需要SQLite 3.38.0及以上版本才能支持JSON_EXTRACT函数,触发的错误信息如下:

WARN  Possible Unhandled Promise Rejection (id: 0):
Array [
  Object {
    "error": [Error: no such function: JSON_EXTRACT (code 1 SQLITE_ERROR): , while compiling: CREATE INDEX IF NOT EXISTS "rxdb_deleted_lastWriteTime_idx" ON "_rxdb_internal-0"(JSON_EXTRACT(data, '$.deleted'), JSON_EXTRACT(data, '$.lastWriteTime'), deleted);],
  },
]

尝试过的不兼容SQLite库(均无法满足需求)

  • expo-sqlite:缺失JSON_EXTRACT函数
  • react-native-sqlite-storage:触发TypeError: e is not a function错误
  • react-native-sqlite-2:无法在Expo中加载,触发null is not an object (evaluating 'RNSqlite2.exec')错误
  • react-native-quick-sqlite:无法在Expo中加载,触发Error: Base quick-sqlite module not found错误

注:曾自行开发expo-sqlite-storage模块,但暂无法在ExpoGO中使用。

最终解决方案

使用v14及以上版本的RxDB,搭配50及以上版本的Expo SDK即可开箱即用,不同SDK版本的导入方式如下:

  • Expo SDK 50:import * as ExpoSqliteStorage from 'expo-sqlite';
  • Expo SDK 51:import * as ExpoSqliteStorageLegacy from 'expo-sqlite/legacy';(该方式将在SDK 52移除)
  • Expo SDK 52:import * as ExpoSqliteStorage from 'expo-sqlite';

内容的提问来源于stack exchange,提问作者jwallet

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 14:30:16