Skip to content
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

App Bundle: MissingLibraryException #5977

Closed
Jeff11 opened this issue May 28, 2018 · 54 comments
Closed

App Bundle: MissingLibraryException #5977

Jeff11 opened this issue May 28, 2018 · 54 comments

Comments

@Jeff11
Copy link

Jeff11 commented May 28, 2018

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

@cmelchior
Copy link
Contributor

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.

@Jeff11
Copy link
Author

Jeff11 commented May 29, 2018

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.

@chriswiesner
Copy link

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

@nhachicha
Copy link
Collaborator

@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

@Jeff11
Copy link
Author

Jeff11 commented Jun 11, 2018

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.

@sdeff
Copy link

sdeff commented Jun 14, 2018

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

bildschirmfoto 2018-06-14 um 22 50 51

@cmelchior
Copy link
Contributor

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.

@philippb
Copy link

philippb commented Jul 9, 2018

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.
KeepSafe/ReLinker#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".

@cmelchior
Copy link
Contributor

A PR is currently in review that should fix this: KeepSafe/ReLinker#46
Once this PR has been approved and merged we will upgrade the Relinker version used.

@cmelchior
Copy link
Contributor

Support for App Bundles has been merged to Relinker master branch. It seems that only KeepSafe/ReLinker#51 needs to be merged before a release is made.

@tamtom
Copy link

tamtom commented Sep 3, 2018

@cmelchior when it will be released?

@nhachicha
Copy link
Collaborator

@cmelchior It looks like ReLinker released 1.3.0 with the fix, we should test it & release a minor

@amatsegor
Copy link

amatsegor commented Sep 20, 2018

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?

@cmelchior
Copy link
Contributor

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

@roberhofer
Copy link

@cmelchior : I believe that Realm Java 5.6.0 has been released with a fix for this ticket. Can you verify and close?

@HungTDO
Copy link

HungTDO commented Jul 8, 2019

Any update or new information about this issues?
My Crashlytics received many errors:
Caused by com.getkeepsafe.relinker.MissingLibraryException lib/x86/librealm-jni.so com.getkeepsafe.relinker.ApkLibraryInstaller.installLibrary (ApkLibraryInstaller.java:85) com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal (ReLinkerInstance.java:180) com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary (ReLinkerInstance.java:136) com.getkeepsafe.relinker.ReLinker.loadLibrary (ReLinker.java:70) com.getkeepsafe.relinker.ReLinker.loadLibrary (ReLinker.java:57) io.realm.internal.RealmCore.loadLibrary (RealmCore.java:60) io.realm.Realm.init (Realm.java:200) com.demo.AppApplication.onCreate (AppApplication.java:59)

@ankuryadav7
Copy link

Have just update the classpath to classpath "io.realm:realm-gradle-plugin:5.11.0"

@lucasrafagnin
Copy link

Does this issue still happen? Or can I update my app to use the app bundle?

@usernotnull
Copy link

+1

@lucasrafagnin unfortunately still does for a random small percentage of users

@andrelramos
Copy link

+1

2 similar comments
@zmunm
Copy link

zmunm commented Aug 6, 2019

+1

@diegoaces
Copy link

+1

@Zhuinden
Copy link
Contributor

You are most likely missing this check on YOUR side: https://developer.android.com/guide/app-bundle/sideload-check#application_class_check

You should make sure that the APK installed by the user has the library variant in Realm.

If you are using Android App Bundle, then you should have this check in your Application class.

This is not a problem with Realm.

@Jeff11
Copy link
Author

Jeff11 commented Aug 14, 2019

@Zhuinden the MissingSplitsManager didn't work for me when I tried an APK with ndk { abiFilters "mips" } on a x86 emulator.

Instead I'm catching the RuntimeException and show a toast.

@Zhuinden
Copy link
Contributor

Zhuinden commented Aug 14, 2019

@Jeff11 hmm I thought abiFilters requires you to specify what to keep (and Realm doesn't support MIPS), and not what to exclude.

Maybe try

abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'

@Jeff11
Copy link
Author

Jeff11 commented Aug 14, 2019

My intention was to build an APK that is not compatible and therefore disableAppIfMissingRequiredSplits() is true and the app won't start.

But disableAppIfMissingRequiredSplits() was false.

@Zhuinden
Copy link
Contributor

But was it actually an Android App bundle, and not an APK?

@Jeff11
Copy link
Author

Jeff11 commented Aug 14, 2019

An APK. When using the App Bundle, you would first have to extract an APK with a single ABI from it. That I didn't test.

@Zhuinden
Copy link
Contributor

missing required splits should only be relevant when Android App Bundle is used.

@Mihir3646
Copy link

@koichi-ozaki
Copy link

https://realm.io/docs/java/latest/#faq-librealm-jni

I tried this method and it crashed.
Is there no solution?

Device Information:
Device: Nexus 5X
Android Version: 6.0.1

Realm Version: 5.14.0

Logcat:
Caused by e.f.a.b: librealm-jni.so
       at com.getkeepsafe.relinker.ApkLibraryInstaller.installLibrary + 123(ApkLibraryInstaller.java:123)
       at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal + 180(ReLinkerInstance.java:180)
       at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary + 136(ReLinkerInstance.java:136)
       at com.getkeepsafe.relinker.ReLinker.loadLibrary + 70(ReLinker.java:70)
       at com.getkeepsafe.relinker.ReLinker.loadLibrary + 57(ReLinker.java:57)
       at io.realm.internal.RealmCore.loadLibrary + 60(RealmCore.java:60)
       at io.realm.Realm.initializeRealm + 322(Realm.java:322)
       at io.realm.Realm.init + 265(Realm.java:265)

@drofnnuD
Copy link

drofnnuD commented Sep 10, 2019

https://realm.io/docs/java/latest/#faq-librealm-jni

This happens every time I try to run my app on a device, without fail. I'm happy to provide more code if requested.

I've also tried this method and it made no difference, it's still crashing on Realm.init() in my Application Class.

All of this started after trying to update the application build.gradle with the latest version of Braintree 3D secure, it wouldn't build so I migrated the project to use androidx, now the project builds, and the app will install, it just falls down on Realm.init() constantly.

Device Information:
Device: Google Pixel 3 XL
Android Version: 9

Realm Version:

5.14.0

Logcat output


2019-09-10 11:47:13.735 29660-29660/com.companyname.androidapps.companyname E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.companyname.androidapps.skiddle, PID: 29660
    java.lang.RuntimeException: Unable to create application com.companyname.androidapps.companyname.ApplicationController: com.getkeepsafe.relinker.MissingLibraryException: librealm-jni.so
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5758)
        at android.app.ActivityThread.-wrap1(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6518)
        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: com.getkeepsafe.relinker.MissingLibraryException: librealm-jni.so
        at com.getkeepsafe.relinker.ApkLibraryInstaller.installLibrary(ApkLibraryInstaller.java:123)
        at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:180)
        at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:136)
        at com.getkeepsafe.relinker.ReLinker.loadLibrary(ReLinker.java:70)
        at com.getkeepsafe.relinker.ReLinker.loadLibrary(ReLinker.java:57)
        at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:60)
        at io.realm.Realm.initializeRealm(Realm.java:322)
        at io.realm.Realm.init(Realm.java:265)
        at com.companyname.androidapps.companyname.ApplicationController.onCreate(ApplicationController.java:39)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1120)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5755)

@dotrinh-DM
Copy link

Have just update the classpath to classpath "io.realm:realm-gradle-plugin:5.11.0"

the same me, i upgraded to 6.0.0. It works.

@ilexbor
Copy link

ilexbor commented Nov 13, 2019

Gradle plugin: "io.realm:realm-gradle-plugin:6.0.0"
Android App Bundle
Android: 6.0.1
Device: Nexus 4

Fatal Exception: java.lang.RuntimeException: Unable to create application Application: com.getkeepsafe.relinker.MissingLibraryException: librealm-jni.so
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4714)
       at android.app.ActivityThread.-wrap1(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1408)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5421)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by com.getkeepsafe.relinker.MissingLibraryException: librealm-jni.so
       at com.getkeepsafe.relinker.ApkLibraryInstaller.installLibrary(ApkLibraryInstaller.java:123)
       at com.getkeepsafe.relinker.ReLinkerInstance.loadLibraryInternal(ReLinkerInstance.java:180)
       at com.getkeepsafe.relinker.ReLinkerInstance.loadLibrary(ReLinkerInstance.java:136)
       at com.getkeepsafe.relinker.ReLinker.loadLibrary(ReLinker.java:70)
       at com.getkeepsafe.relinker.ReLinker.loadLibrary(ReLinker.java:57)
       at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:60)
       at io.realm.Realm.initializeRealm(Realm.java:322)
       at io.realm.Realm.init(Realm.java:265)
       at epayservice.kotlin.controller.RealmController.create(RealmController.java:23)
       at epayservice.kotlin.controller.App.onCreate(App.java:63)
       at epayservice.kotlin.controller.Application.onCreate(Application.java:21)
       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1022)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4711)
       at android.app.ActivityThread.-wrap1(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1408)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:148)
       at android.app.ActivityThread.main(ActivityThread.java:5421)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

@cmelchior
Copy link
Contributor

Folding this into #6673

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests