objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence
https://docs.objectbox.io/getting-started
Apache License 2.0
927 stars 115 forks source link

ObjectBoxException on Windows with Flutter: "failed to create store: Incoming entity ID does not match existing UID" #627

Closed pedrosotc closed 2 weeks ago

pedrosotc commented 3 weeks ago

I am developing a Flutter application using ObjectBox as the database. The application works fine on an Android device connected via USB, but when I try to run it on the Windows desktop environment provided by Flutter, I encounter a persistent issue.

The specific error message I receive is:

Unhandled Exception: ObjectBoxException: failed to create store: Incoming entity ID 1:5518923810860262496 does not match existing UID 4909511370117383253

This error does not occur when running the application on the Android device. Here are the steps and configurations I've tried:

Ensured consistent objectbox-model.json across both platforms. Deleted and regenerated objectbox-model.json and related files. Verified entity definitions and annotations are correct and consistent. Repeatedly run flutter pub run build_runner build --delete-conflicting-outputs to resolve any potential conflicts in generated files. Despite these efforts, the error persists exclusively in the Windows environment. I'm looking for insights on why this discrepancy occurs and how to resolve it so that the application functions smoothly across both platforms.

Any advice on how to troubleshoot and fix this issue would be greatly appreciated. Thank you!

I have attempted several solutions to resolve the ObjectBoxException error on my Windows environment. Initially, I expected that regenerating the ObjectBox model files with flutter pub run build_runner build --delete-conflicting-outputs would resolve any inconsistencies in entity IDs and UIDs. This method usually fixes such issues by cleaning up and rebuilding the necessary files. However, despite multiple attempts, the error persists when running on Windows, although no issues arise when the application is run on an Android device.

I also tried manually deleting and recreating the ObjectBox model files, ensuring that the entity definitions in my Dart code matched the schema expected by ObjectBox. My expectation was that a fresh setup would eliminate any discrepancies causing the error. Unfortunately, this did not change the outcome on Windows, though everything functioned as expected on Android. The discrepancy in behavior between the two environments was unexpected and remains unresolved.

greenrobot-team commented 2 weeks ago

@pedrosotc Please don't double post here and on Stack Overflow, it means less time to actually help you! ❤️

Answer on SO: https://stackoverflow.com/a/78400833/9187282