android-RealmDB-React Native-无法在路径’.management’打开领域

在Genymotion上运行Android的本机项目中,我运行了该应用程序.有一次我收到一个问题,并从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-在Kotlin项目中应用Realm插件会导致编译错误


下一篇:java-无法使用Kotlin在项目中设置Realm