Solutions for common issues with ObjectBox for Java, Kotlin and Android
Make sure you do not have any other errors in your build. There have been problems reported in relation to “android-apt”, so remove it from your build if possible. For Kotlin, explicitly apply the kapt plugin (
apply plugin: 'kotlin-kapt') before the ObjectBox plugin.
If your team makes concurrent modifications to the data model (e.g. adding/removing entities or properties) it may clash with your changes. Read the meta model docs on how to resolve the conflicts.
You might get an exception like
DbException DB’s last entity ID 4 is higher than 3 from model after switching back from a branch and running your app. This is expected if that branch makes incompatible changes to entities. You need to uninstall or clear all data of your app before running it again.
Here is why: Let’s say you have created a new entity on a new branch and ran your app on a device. This will upgrade the ObjectBox database on that device to support the new entity (ObjectBox keeps track of entity types internally by storing some meta info inside the database). Now, when you return to your previous branch and try to run the app ObjectBox will fail with an error message similar to the one above. This is because the entity types passed by your code no longer match those stored inside the database. In other words, the database can not be downgraded to the previous version. Thus, it is advised to clear the database before running your app after switching branches. Check the meta model docs for more details.
This can have various reasons. In general check your ABI filter setup or add one in your Gradle build file.
If your app explicitly ships code for "armeabi": For Android, ObjectBox comes with binaries for “armeabi-v7a” and “arm64-v8a” ABIs. We consider “armeabi” to be outdated and thus do not support it. Check if you have a Gradle config like abiFilters "armeabi", which is causing the problem (e.g. remove it or change it to “armeabi-v7a”).
If your app uses split APKs or App Bundle: some users might have sideloaded your APK that includes the library for a platform that is incompatible with the one of their device.
Extracting the native library failed: starting with Android 6.0 (M) you can avoid error-prone extraction by adding
android:extractNativeLibs=”false” to the application tag in your manifest.
If you are doing Android instrumentation (especially with Espresso), you may get a warning like this:
Error:Conflict with dependency ‘com.google.code.findbugs:jsr305’ in project ‘:app’. Resolved versions for app (3.0.2) and test app (2.0.1) differ. See
You can easily resolve the version conflict by adding this Gradle dependency:
Check the data model migration guide if you get an exception like:
io.objectbox.exception.DbException: Property […] is not compatible to its previous definition. Check its type.
Cannot change the following flags for Property
If you believe to have found a bug or missing feature, please create an issue. https://github.com/objectbox/objectbox-java/issues
If you have a usage question regarding ObjectBox, please post on Stack Overflow. https://stackoverflow.com/questions/tagged/objectbox