Skip to content

io.objectbox.exception.DbException: Schema entity could not be verified for key 2 #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
yocn opened this issue Nov 30, 2017 · 6 comments
Closed

Comments

@yocn
Copy link

yocn commented Nov 30, 2017

Version:1.2.1

Exception:
FATAL EXCEPTION: main Process: philm.vilo.im, PID: 18973 java.lang.RuntimeException: Unable to create application com.android.APP: io.objectbox.exception.DbException: Schema entity could not be verified for key 2 at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4812) at android.app.ActivityThread.access$1700(ActivityThread.java:156) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:157) at android.app.ActivityThread.main(ActivityThread.java:5637) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:746) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636) Caused by: io.objectbox.exception.DbException: Schema entity could not be verified for key 2 at io.objectbox.BoxStore.nativeCreate(Native Method) at io.objectbox.BoxStore.<init>(BoxStore.java:190) at io.objectbox.BoxStoreBuilder.build(BoxStoreBuilder.java:270) at com.objectbox.manager.ObjectBoxManager.init(ObjectBoxManager.java:51) at com.android.App.onCreate(App.java:154) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4809) at android.app.ActivityThread.access$1700(ActivityThread.java:156)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:157)  at android.app.ActivityThread.main(ActivityThread.java:5637)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:746)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636) 

Exception Line:

BoxStoreBuilder builder = MyObjectBox.builder().baseDirectory(new File(TietieFileSystem2.sLocalRoot)); boxStore = builder.build(); if (BuildConfig.DEBUG) { new AndroidObjectBrowser(boxStore).start(context); }

I try to specify the location of where the DB files should be stored, when open app next time , this Exception will be happen. And I can find the mdb file in the dir, This cannot use in this way?

@yocn
Copy link
Author

yocn commented Nov 30, 2017

I think its my problem to invoke builder.
No problem if I write like this:
File directory = new File(TietieFileSystem2.sLocalRoot); builder.androidContext(context).directory(directory); boxStore = builder.build();

but I want ask a question:
can I use a preload mdb file to accelerate the init speed?
I specify a path which contain a preCreated data.mdb and a lock.mdb.
is this method useful?

@greenrobot
Copy link
Member

Do I understand correctly that it fails only if you try to access a mdb file that you previously copied there? Where does this file originate from?

@yocn
Copy link
Author

yocn commented Dec 1, 2017

1、seems no problem if I access a mdb that I reviously copied in directory.
2、this mdb is I generated in normal directory.
for example: If I want build-in two records in app, I will generate 2 records in my developing period (may be these records is come from jsons or something else), I will copy these data.mdb and lock.mdb to my asserts file, and when the first time I run my app, I will copy these mdbs to my file directory, and specify BoxStoreBuilder.directory to this directory.
I think this logic will be faster my app's first boot, will optimize my boot time. And could you please give some advices for this logic?

@greenrobot
Copy link
Member

At the moment we have no guarantee that data files can be copied from one device to another. While there are efforts to make the data file architecture independent, it's nothing we test for yet. Let me investigate a bit and I'll come back to you later. So, right now, the safest path would be not to bundle a data.mdb file with your app.

@yocn
Copy link
Author

yocn commented Dec 5, 2017

Got it, Please let me know whether it is feasible , Thanks .

@greenrobot
Copy link
Member

Closing this, it's now tracked via #310

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants