App Bundle: MissingLibraryException
Goal
To find a solution for ABI related problems
Expected Results
To run all split versions of app successfully
Actual Results
Fatal Exception: java.lang.RuntimeException: Unable to create application my.app.AppMain: com.b.a.b: lib/armeabi/librealm-jni.so
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4715)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
Caused by com.b.a.b: lib/armeabi/librealm-jni.so
at com.b.a.a.a(ApkLibraryInstaller.java:85)
at com.b.a.d.a(ReLinkerInstance.java:180)
at com.b.a.d.a(ReLinkerInstance.java:136)
at com.b.a.c.a(ReLinker.java:1070)
at io.realm.internal.m.a(RealmCore.java:60)
at io.realm.v.a(Realm.java:258)
at my.app.AppMain.onCreate(AppMain.java:256)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4712)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
Version of Realm and tooling
Realm version(s): 5.1.0 Android Studio version: 3.2 canary 15
Which Android version and device: Nexus 5X tries to load x86, but most reported devices try armeabi Many different devices are affected App is not using other so files than Realm.
From the Google Play dashboard I can see that no armeabi version is generated, only the 5 that Realm uses.
Edit: removed the x86 from the stacktrace, that was confusing
Hi @Jeff11 Thanks for reporting this. I haven't had a chance to use App Bundles yet, and since the feature was just released I will need to play around with it to determine what might be causing this.
This message looks rather strange though: lib/armeabi or x86/librealm-jni.so, since a phone only have one architecture.
That was confusing from my side, sorry. Of course, either x86 or armeabi was loaded per device, not both.
This crash happens on <0.2% of devices.
I have a similar issue using Android App Bundle.
Caused by com.getkeepsafe.relinker.MissingLibraryException
lib/x86/librealm-jni.so
arrow_right
com.getkeepsafe.relinker.ApkLibraryInstaller.a (Unknown Source)
com.getkeepsafe.relinker.ReLinkerInstance.b (Unknown Source)
com.getkeepsafe.relinker.ReLinkerInstance.a (Unknown Source)
com.getkeepsafe.relinker.ReLinker.a (Unknown Source)
io.realm.internal.RealmCore.a (Unknown Source)
io.realm.Realm.a (Unknown Source)
and
Caused by com.getkeepsafe.relinker.MissingLibraryException
lib/armeabi/librealm-jni.so
com.getkeepsafe.relinker.ApkLibraryInstaller.a (Unknown Source)
com.getkeepsafe.relinker.ReLinkerInstance.b (Unknown Source)
com.getkeepsafe.relinker.ReLinkerInstance.a (Unknown Source)
com.getkeepsafe.relinker.ReLinker.a (Unknown Source)
io.realm.internal.RealmCore.a (Unknown Source)
io.realm.Realm.a (Unknown Source)
Filed an issue on Google side to check if it's a fault on the bundle system itself: https://issuetracker.google.com/issues/109448556
@Jeff11 Are you using another library which uses armeabi, my guess is the bundle created an APK based on this configuration (CPU = armeabi) but as you know Realm stopped supporting armeabi since 2.x (Following Google deprecation on this ABI).
You can now double check the generated APK locally using bundletool as described by the official doc & see if you can reproduce the issue before pushing to Play
I have no other libraries that use armeabi. Realm is the only native library in use.
After uploading the AAB to the play store, I am able to download the APKs by device and they worked fine.
I'm experiencing the same issue with Android App Bundle:
Caused by com.getkeepsafe.relinker.MissingLibraryException: lib/armeabi/librealm-jni.so
at com.getkeepsafe.relinker.a.a(ApkLibraryInstaller.java:85)
at com.getkeepsafe.relinker.c.c(ReLinkerInstance.java:180)
at com.getkeepsafe.relinker.c.a(ReLinkerInstance.java:136)
at com.getkeepsafe.relinker.b.a(ReLinker.java:70)
at com.getkeepsafe.relinker.b.a(ReLinker.java:57)
at io.realm.internal.l.a(RealmCore.java:60)
at io.realm.v.a(Realm.java:258)
Strangely only on devices which use MediaTek chipsets like:
Quantum MUV PRO - MediaTek MT6753 Lenovo PHAB 2 Plus - MediaTek MT8783 Xperia XA - MediaTek MT6755 Helio P10 Sony Xperia XA1 Ultra Dual - MediaTek MT6757 Helio P20

From the comments in https://issuetracker.google.com/issues/109448556 It seems that this is related to side-loaded APK's. Before, if you didn't manually use ABI split, the APK would contain all the code needed for all CPU architectures. With App Bundle a split is happening automatically and if people are distributing the APK to devices with a different architecture, the app will crash with the above message.
I have been told this is behaviour is quite common in areas where data traffic might be expensive.
Unfortunately, there isn't much we can do about this as it is a "user error". The best we can do is probably having a better check if we cannot match the CPU architecture with the native code found. If that happens we can throw a better exception. App developers can then use this exception to show a dialogue to the user saying the app doesn't work on their device.
I'll keep this issue open as it hasn't been closed on Googles side yet, so we cannot yet rule out a bug on their end.
It looks like the our ReLinker has problems loading native libs from AppBundles as we only look in the base APK for the native library. https://github.com/KeepSafe/ReLinker/issues/44 Sums this up.
We would be very happy about a PR on this, as we don't use AppBundles our selfs. The following comment from a google issue sums it up quite well:
ReLinker loads the native library directly from the APK file, without using the OS' System.load() or System.loadLibrary() methods. The issue is that it searches for the native libraries in the base APK, whereas with the App Bundle, the native libraries are in config splits (i.e. ReLinker searches in base.apk whereas the native libraries are actually in base-x86.apk, base-armeabi.apk, etc.).
Source: https://github.com/KeepSafe/ReLinker/blob/master/relinker/src/main/java/com/getkeepsafe/relinker/ApkLibraryInstaller.java#L55 Instead of searching in "sourceDir", ReLinker should be searching over the different directories under "splitSourceDirs".
A PR is currently in review that should fix this: https://github.com/KeepSafe/ReLinker/pull/46 Once this PR has been approved and merged we will upgrade the Relinker version used.
Support for App Bundles has been merged to Relinker master branch. It seems that only https://github.com/KeepSafe/ReLinker/pull/51 needs to be merged before a release is made.
@cmelchior when it will be released?
@cmelchior It looks like ReLinker released 1.3.0 with the fix, we should test it & release a minor
Waiting for a 5.5.1 version really much, it's the only obstacle for us to make an APK almost three times smaller. Are there any estimates for this release?
Yes, the plan is to release it next week. Our SNAPSHOT uploads have been broken, but should work again, so you can also test it by using our 5.6.0-SNAPSHOT release: https://github.com/realm/realm-java#using-snapshots
@cmelchior : I believe that Realm Java 5.6.0 has been released with a fix for this ticket. Can you verify and close?
Yes, a fix has been released in 5.6.0
Unfortunately, I still get the same issue with Realm version 5.7.0.
Samsung SM-G965F LGE Nexus 5X

@MeinLieberScholli , Do you have any idea if Is this problem has been solved in 5.8.0? We are getting such crashes from those models on 5.7.1: ANE-LX1,CLT-L09,CLT-L29,SM-N910C,SM-N920C,SM-N960F
@MeinLieberScholli , Do you have any idea if Is this problem has been solved in 5.8.0? We are getting such crashes from those models on 5.7.1: ANE-LX1,CLT-L09,CLT-L29,SM-N910C,SM-N920C,SM-N960F
i will update in a few days and report if it occurs again.
I'm reopening this issue as we are seeing some reports of there perhaps still being problems with App Bundle.
Note, we are using Relinker to load our .so files so if there still are problems it is most likely in either Relinker (https://github.com/KeepSafe/ReLinker) or the App Bundle feature itself.
That said, we are still interested in finding and fixing bugs in any of these components.
@MeinLieberScholli @engi2nee Is it something you can reproduce locally?
Note that upgrading to 5.8.0 should not fix it as we haven't touched this part of the code in that release.