【问题标题】:error crashlytics firebase after renameFieldrenameField 后出现错误 crashlytics firebase
【发布时间】:2020-09-24 03:15:48
【问题描述】:

错误:in realm, io.realm.RealmObjectSchema.checkFieldExists: Field name doesn't exist on object "ModelName": "oldField" 在 renameField 之后,我在 firebase 中收到此错误,但不知何故,当我从 android studio 构建和运行时,我的应用程序运行良好,没有问题。我尝试重现此错误。但它没有用。我在代码中没有看到任何问题

这是我在 migration.kt 中的代码:

if (oldVersion == 11L) {
schema.get("ModelName")!!
   .renameField("oldField", "newField")
   oldVersion++
}

我还增加了迁移模式

【问题讨论】:

    标签: java android kotlin migration realm


    【解决方案1】:

    如果您想从领域迁移,dynamicRealm 旨在打开 Realm 文件而不检查架构。

    要删除版本 0 的 Realm 文件,您可以执行以下操作:

    File file = new File(realmConfig.getPath());
     if (file.exist()) {
     DynamicRealm dynamicRealm = DynamicRealm.getInstance(realmConfig);
     long version = dynamicRealm.getVersion();
     dynamicRealm.close();
     if (version == 0) {
        Realm.deleteRealm(realmConfig);
    }
    

    }

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-12
      • 2020-08-30
      • 1970-01-01
      • 1970-01-01
      • 2018-08-24
      • 2018-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多