RealmDB-React Native-无法在路径'.management'中打开领域

Jon*_*ker 3 android realm genymotion react-native

在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
Run Code Online (Sandbox Code Playgroud)

我尝试关闭Genymotion,通过adb shell卸载,通过adb shell手动设置权限。我似乎无法解决问题。

有什么建议么?

谢谢!

gus*_*ard 5

由于迁移,我遇到了同样的问题。在ios中工作正常,但在android中却没有。

之前的代码

let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath);
while (nextSchemaIndex < schemas.length) {
  const migratedRealm = new Realm(schemas[nextSchemaIndex]);
  nextSchemaIndex += 1;
  migratedRealm.close();
}
Run Code Online (Sandbox Code Playgroud)

立即编码

let nextSchemaIndex = Realm.schemaVersion(Realm.defaultPath);
while (nextSchemaIndex < schemas.length) {
  const migratedRealm = new Realm({ ...schemas[nextSchemaIndex] });
  nextSchemaIndex += 1;
  migratedRealm.close();
}
Run Code Online (Sandbox Code Playgroud)

为Realm构造函数创建一个新对象可以解决此问题。

希望对您有所帮助。

我没有设定模式的路径,但也许可以帮助也。