objectbox / objectbox-java

Android Database - first and fast, lightweight on-device vector database
https://objectbox.io
Apache License 2.0
4.41k stars 302 forks source link

CRASH on App start - Caused by java.lang.LinkageError #1029

Closed mchilikin closed 2 years ago

mchilikin commented 2 years ago

Bug description

Our app crashes on application start in production with the following exception according to Firebase:

Caused by java.lang.LinkageError: [ObjectBox] Loading native library failed, please report this to us: vendor=The Android Project,os=linux,os.arch=armv8l,model=null,android=true,linux=true,machine=armv8l at io.objectbox.internal.NativeLibraryLoader.(NativeLibraryLoader.java:115) at io.objectbox.internal.NativeLibraryLoader.ensureLoaded(NativeLibraryLoader.java) at io.objectbox.BoxStore.(BoxStore.java:257) at io.objectbox.BoxStoreBuilder.build(BoxStoreBuilder.java:516)

Basic info

To Reproduce Steps to reproduce the behavior:

  1. Launch the app
  2. App crashes

Expected behavior App shouldn't crash

Code There is no specific code just object box initialization: MyObjectBox .builder() .androidContext(context.applicationContext) .build()

Logs, stack traces Caused by java.lang.LinkageError: [ObjectBox] Loading native library failed, please report this to us: vendor=The Android Project,os=linux,os.arch=armv8l,model=null,android=true,linux=true,machine=armv8l at io.objectbox.internal.NativeLibraryLoader.(NativeLibraryLoader.java:115) at io.objectbox.internal.NativeLibraryLoader.ensureLoaded(NativeLibraryLoader.java) at io.objectbox.BoxStore.(BoxStore.java:257) at io.objectbox.BoxStoreBuilder.build(BoxStoreBuilder.java:516)

Or

Caused by java.lang.LinkageError: [ObjectBox] Loading native library failed, please report this to us: vendor=The Android Project,os=linux,os.arch=armv7l,model=null,android=true,linux=true,machine=armv7l at io.objectbox.internal.NativeLibraryLoader.(NativeLibraryLoader.java:115) at io.objectbox.internal.NativeLibraryLoader.ensureLoaded(NativeLibraryLoader.java) at io.objectbox.BoxStore.(BoxStore.java:257) at io.objectbox.BoxStoreBuilder.build(BoxStoreBuilder.java:516)

Maybe the cause of the issue are armv7l and armv8l?

Additional context Add any other context about the problem here. I found only this article with similar problem: https://objectbox.io/app-bundle-and-sideloading-how-to-prevent-crashes/. But we don't use App Bundle

greenrobot-team commented 2 years ago

Thanks for reporting!

Can you open the built APK or AAB in Android Studio and have a look at the lib folder to see which ABIs are actually included? There should be a folder for armeabi-v7a, arm64-v8a, x86 and x86_64.

Has this happened with older versions, or only since updating to 3.0.1? Are the affected devices different from your whole user base (e.g. it's not surprising that many Samsung devices are affected considering their market share)?

Also, if you have an actual device to reproduce this: can you share the contents of https://developer.android.com/reference/android/os/Build#SUPPORTED_ABIS?

mchilikin commented 2 years ago

Can you open the built APK or AAB in Android Studio and have a look at the lib folder to see which ABIs are actually included?

We have splits for armeabi-v7a, arm64-v8a and x86. At least for armeabi-v7a and arm64-v8a I see that libobjectbox-jni.so is included

Has this happened with older versions, or only since updating to 3.0.1?

Also on 2.9.1, probably on other versions too, we've had only 2.9.1 and 3.0.1

Also, if you have an actual device to reproduce this: can you share the contents of https://developer.android.com/reference/android/os/Build#SUPPORTED_ABIS?

No, unfortunately we haven't reproduce this yet, we decided to report this issue first because of message from stacktrace (Loading native library failed, please report this to us)

greenrobot-team commented 2 years ago

If you are sure that the correct ABI version of libobjectbox-jni.so is included in each split APK, this sounds like some users are side-loading the wrong APK onto their devices. An indicator might be that this only affects a small share of users. This is also explained in more detail with possible workarounds at https://docs.objectbox.io/android/app-bundle-and-split-apk#app-bundle-and-split-apks

greenrobot-team commented 2 years ago

Closing as this appears to be resolved. ✅ Feel free to comment with more information or create a new issue.