在 Genymotion 上运行 Android 的 react-native 项目中,我运行了该应用程序。有一次我收到一个问题并从 VM 中卸载了该应用程序。重新运行该应用后,我收到了一条警告:
Unable to open a realm at path '.management'.
Please use a path where your app has read-write permissions. <unknown>
index.js:100 loadModuleImplementation
require.js:171 guardedLoadModule
require.js:123
_require
require.js:107 <unknown>
Repeaters.js:6 loadModuleImplementation
require.js:171 guardedLoadModule
require.js:123
_require
require.js:107 <unknown>
NavigationRouter.js:12 loadModuleImplementation
require.js:171 guardedLoadModule
require.js:123
_require
require.js:107 <unknown>
RootContainer.js:5 loadModuleImplementation
require.js:171 guardedLoadModule
require.js:123
_require
require.js:107 <unknown>
index.android.js:8 loadModuleImplementation
require.js:171 guardedLoadModule
require.js:116
_require
require.js:107 global code
require-0.js:1
我试过关闭 Genymotion,通过 adb shell 卸载,通过 adb shell 手动设置权限。我似乎无法解决问题。
有什么建议吗?
谢谢!
最佳答案
由于 migrations,我遇到了同样的问题.在 ios 中工作正常但在 android 中没有。
之前的代码
let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath);
while (nextSchemaIndex < schemas.length) {
const migratedRealm = new Realm(schemas[nextSchemaIndex]);
nextSchemaIndex += 1;
migratedRealm.close();
}
现在编码
let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath);
while (nextSchemaIndex < schemas.length) {
const migratedRealm = new Realm({ ...schemas[nextSchemaIndex] });
nextSchemaIndex += 1;
migratedRealm.close();
}
为 Realm 构造函数创建一个新对象解决了这个问题。
希望对您有所帮助。
我没有为架构设置路径,但可能是 this也有帮助。
关于android - RealmDB - React Native - 无法在路径 '.management' 打开 Realm ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41657077/