After refactoring the android project to androidX I'm unable to solve this issue. Previously i've faced this as well. But after invaliding cache and objectbox old models it worked.
java.lang.LinkageError: Loading ObjectBox native library failed: vendor=The Android Project,os=linux,arch=null,android=true,linux=true
at io.objectbox.internal.NativeLibraryLoader.(NativeLibraryLoader.java:108)
at io.objectbox.internal.NativeLibraryLoader.ensureLoaded(NativeLibraryLoader.java:179)
at io.objectbox.BoxStore.(BoxStore.java:197)
at io.objectbox.BoxStoreBuilder.build(BoxStoreBuilder.java:383)
at objectBox.ObjectBox.init(ObjectBox.java:14)
at bp.MyApplication.onCreate(MyApplication.java:27)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.sfdw.shaktisme-B3j8NkRgRvEwUVUYBG33XA==/base.apk"],nativeLibraryDirectories=[/data/app/com.sfdw.shaktisme-B3j8NkRgRvEwUVUYBG33XA==/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libobjectbox-jni.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1011)
at java.lang.System.loadLibrary(System.java:1657)
Thanks for reporting. In our tests we have not come across any issue when migrating to AndroidX.
Are you using App Bundle? Make sure you install an APK built for the architecture of your test device/emulator. There is a detailed explanation of this issue at https://objectbox.io/app-bundle-and-sideloading-how-to-prevent-crashes/
Anyhow, make sure to rebuild your project. Also check the required flags were added to gradle.properties.
https://developer.android.com/jetpack/androidx/migrate
@atiartalukdar I came across this issue before, but when I modularized my app. In my project, my ObjectBox logic was written within a plain Kotlin "datastore" module and accessed by other modules, including dynamic feature modules.
In short, the fix for me was to make sure I have apply plugin: 'io.objectbox' as the last defined plugin in BOTH my datastore module's gradle file and my application's gradle file. There may be a cleaner solution, but this is what worked for me.
Thank you very much.
Most helpful comment
@atiartalukdar I came across this issue before, but when I modularized my app. In my project, my ObjectBox logic was written within a plain Kotlin "datastore" module and accessed by other modules, including dynamic feature modules.
In short, the fix for me was to make sure I have
apply plugin: 'io.objectbox'as the last defined plugin in BOTH my datastore module's gradle file and my application's gradle file. There may be a cleaner solution, but this is what worked for me.