realm / realm-kotlin

Kotlin Multiplatform and Android SDK for the Realm Mobile Database: Build Better Apps Faster.
Apache License 2.0
923 stars 56 forks source link

UnsatisfiedLinkError: couldn't find "librealmc.so" #1202

Open KennethRichards opened 1 year ago

KennethRichards commented 1 year ago

SDK: realm-kotlin

Version: 'io.realm.kotlin:library-sync:1.5.0', 'io.realm.kotlin:gradle-plugin:1.5.0'

Observations

From Firebase Crashlytics:

Nexus 5X - Android 8.1.0

Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.crystalyze.crystalyze-mp0dbfOJe8A8n38Sjr4jkw==/base.apk"],nativeLibraryDirectories=[/data/app/com.crystalyze.crystalyze-mp0dbfOJe8A8n38Sjr4jkw==/lib/x86, /system/lib, /vendor/lib]]] couldn't find "librealmc.so"
       at java.lang.Runtime.loadLibrary0(Runtime.java:1011)
       at java.lang.System.loadLibrary(System.java:1657)
       at io.realm.kotlin.internal.interop.realmc.<clinit>(realmc.java:16)
       at io.realm.kotlin.internal.interop.RealmInterop.realm_network_transport_new(RealmInterop.java:49)
       at io.realm.kotlin.mongodb.internal.AppConfigurationImpl.initializeRealmAppConfig(AppConfigurationImpl.java:49)
       at io.realm.kotlin.mongodb.internal.AppConfigurationImpl.<init>(AppConfigurationImpl.java:49)
       at io.realm.kotlin.mongodb.AppConfiguration$Builder.build(AppConfiguration.java:68)
       at io.realm.kotlin.mongodb.App$Companion.create(App.java:68)

Galaxy Tab A - Android 7.1.2

Fatal Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.crystalyze.crystalyze-1/base.apk"],nativeLibraryDirectories=[/data/app/com.crystalyze.crystalyze-1/lib/x86_64, /system/lib64, /vendor/lib64]]] couldn't find "librealmc.so"
       at java.lang.Runtime.loadLibrary0(Runtime.java:1001)
       at java.lang.System.loadLibrary(System.java:1562)
       at io.realm.kotlin.internal.interop.realmc.<clinit>(realmc.java)
       at io.realm.kotlin.internal.interop.RealmInterop.realm_network_transport_new(RealmInterop.java:49)
       at io.realm.kotlin.mongodb.internal.AppConfigurationImpl.initializeRealmAppConfig(AppConfigurationImpl.java:49)
       at io.realm.kotlin.mongodb.internal.AppConfigurationImpl.<init>(AppConfigurationImpl.java:49)
       at io.realm.kotlin.mongodb.AppConfiguration$Builder.build(AppConfiguration.java:68)
       at io.realm.kotlin.mongodb.App$Companion.create(App.java:68)

In the APK, librealmc.so exists in /lib/x86_64 /lib/x86 /lib/arm64-v8a /lib/armeabi-v7a

rorbech commented 1 year ago

Hi @KennethRichards Since this only happens on some devices it could be that the so-file for some reason is stripped by Google play when installing the app. Do you have more insight in:

KennethRichards commented 1 year ago

Hi @rorbech This is only happening on the Nexus 5X (Android 8.1.0) and Galaxy Tab A (Android 7.1.2). <1% of users are affected with only 1 of these users being rooted on a Galaxy Tab A. No other patterns for now, but I will continue to monitor

rorbech commented 1 year ago

Hi @KennethRichards. Thanks for the feedback. Are you by any chance distributing other native libraries than ours in your app? We have seen that if some other library is not available for the exact architecture then it can end up only looking for 32-bit libraries on a 64-bit device, and that library could have been stripped as part of the repackaging in playstore.

KennethRichards commented 1 year ago

Hi @rorbech, I checked the Github repos from the other dependencies in our app but did not find any indication of native libraries. To be honest I'm not quite sure how else to check/verify this.

When inspecting the APK though, I can see that librealmc.so is the only file located in the following directories: /lib/x86_64 /lib/x86 /lib/arm64-v8a /lib/armeabi-v7a

cmelchior commented 1 year ago

We have seen a similar problem with Realm Java, and the root cause is still unclear. It is pretty rare, but our best guess is that either APK's are being side-loaded in the wrong way or the Play Store doesn't send down the correct files.

Currently, in Realm Kotlin, we are just loading the native lib in a naive way, which should work, but has a few known edge cases, #1215 will introduce a slightly better way, but it isn't a 100% guarantee it will fix this issue.

ersen-lw commented 1 year ago

Hi all, we got a few reports of this issue. Here is some data if it helps.

Caused by androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: dlopen failed: library "librealmc.so" not found
       at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:187)
       at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238)
       at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206)
       at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45)
       at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
       at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
       at android.app.ActivityThread.installProvider(ActivityThread.java:7262)
       at android.app.ActivityThread.installContentProviders(ActivityThread.java:6803)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6720)
       at android.app.ActivityThread.access$1300(ActivityThread.java:239)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1915)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:223)
       at android.app.ActivityThread.main(ActivityThread.java:7680)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Caused by java.lang.UnsatisfiedLinkError: dlopen failed: library "librealmc.so" not found
       at java.lang.Runtime.loadLibrary0(Runtime.java:1093)
       at java.lang.Runtime.loadLibrary0(Runtime.java:1013)
       at java.lang.System.loadLibrary(System.java:1664)
       at io.realm.kotlin.internal.interop.realmc.<clinit>(realmc.java:18)
       at io.realm.kotlin.internal.interop.realmc.realm_config_new(realmc.java:262)
       at io.realm.kotlin.internal.interop.RealmInterop.realm_config_new(RealmInterop.kt:120)
       at io.realm.kotlin.internal.ConfigurationImpl.createNativeConfiguration(ConfigurationImpl.kt:2)
       at io.realm.kotlin.internal.ConfigurationImpl.openRealm$suspendImpl(ConfigurationImpl.kt:4)
       at io.realm.kotlin.internal.ConfigurationImpl.openRealm(ConfigurationImpl.kt)
ersen-lw commented 1 year ago

Hi all, got a new stack trace related to the above. This occurred on a rooted device.

Fatal Exception: java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: com.getkeepsafe.relinker.MissingLibraryException: Could not find 'librealmc.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: [].
       at android.app.ActivityThread.installProvider(ActivityThread.java:7862)
       at android.app.ActivityThread.installContentProviders(ActivityThread.java:7374)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7081)
       at android.app.ActivityThread.access$1700(ActivityThread.java:277)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2161)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:210)
       at android.os.Looper.loop(Looper.java:299)
       at android.app.ActivityThread.main(ActivityThread.java:8298)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:576)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1073)
sirambd commented 1 year ago

Hi all, we also had the same issue,

Exception

MissingLibraryException: Could not find 'librealmc.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: [].
    at com.getkeepsafe.relinker.ApkLibraryInstaller.installLibrary(ApkLibraryInstaller.java:175)
    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)
...
(21 additional frame(s) were not displayed)

StartupException: com.getkeepsafe.relinker.MissingLibraryException: Could not find 'librealmc.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: [].
    at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:187)
    at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238)
    at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206)
    at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:2516)
...
(13 additional frame(s) were not displayed)

RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: com.getkeepsafe.relinker.MissingLibraryException: Could not find 'librealmc.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: [].
    at android.app.ActivityThread.installProvider(ActivityThread.java:8231)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:7728)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7482)
    at android.app.ActivityThread.access$1600(ActivityThread.java:310)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2281)
...
(7 additional frame(s) were not displayed)
sheinin commented 1 year ago

This error happens every time an APK is extracted from the app installed from PlayStore. Realm 1.9.1, Android 13.


                    at android.app.ActivityThread.installProvider(ActivityThread.java:7728)
                    at android.app.ActivityThread.installContentProviders(ActivityThread.java:7216)
                    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6960)
                    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2218)
                    at android.os.Handler.dispatchMessage(Handler.java:106)
                    at android.os.Looper.loopOnce(Looper.java:242)
                    at android.os.Looper.loop(Looper.java:359)
                    at android.app.ActivityThread.main(ActivityThread.java:8133)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)
                 Caused by: androidx.startup.StartupException: com.getkeepsafe.relinker.MissingLibraryException: Could not find 'librealmc.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: [].
                    at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:187)
                    at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238)
                    at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206)
                    at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45)
                    at android.content.ContentProvider.attachInfo(ContentProvider.java:2502)
                    at android.content.ContentProvider.attachInfo(ContentProvider.java:2472)
                    at android.app.ActivityThread.installProvider(ActivityThread.java:7723)
                    at android.app.ActivityThread.installContentProviders(ActivityThread.java:7216) 
                    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6960) 
                    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) 
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2218) 
                    at android.os.Handler.dispatchMessage(Handler.java:106) 
                    at android.os.Looper.loopOnce(Looper.java:242) 
                    at android.os.Looper.loop(Looper.java:359) 
                    at android.app.ActivityThread.main(ActivityThread.java:8133) 
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942) 
                 Caused by: com.getkeepsafe.relinker.MissingLibraryException: Could not find 'librealmc.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: [].
                    at com.getkeepsafe.relinker.ApkLibraryInstaller.installLibrary(ApkLibraryInstaller.java:175)
                    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.kotlin.internal.AndroidUtilsKt.loadAndroidNativeLibs(AndroidUtils.kt:14)
                    at io.realm.kotlin.internal.RealmInitializer.create(RealmInitializer.kt:42)
                    at io.realm.kotlin.internal.RealmInitializer.create(RealmInitializer.kt:30)
                    at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:180)
                    at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238) 
                    at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206) 
                    at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45) 
                    at android.content.ContentProvider.attachInfo(ContentProvider.java:2502) 
                    at android.content.ContentProvider.attachInfo(ContentProvider.java:2472) 
                    at android.app.ActivityThread.installProvider(ActivityThread.java:7723) 
                    at android.app.ActivityThread.installContentProviders(ActivityThread.java:7216) 
                    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6960) 
                    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) 
                    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2218) 
                    at android.os.Handler.dispatchMessage(Handler.java:106) 
                    at android.os.Looper.loopOnce(Looper.java:242) 
                    at android.os.Looper.loop(Looper.java:359) 
                    at android.app.ActivityThread.main(ActivityThread.java:8133) 
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942) ```
ChrisKruegerDev commented 1 year ago

We have around 350 crashes with the same exception, starting with the realm-kotlin integration.

The device range and system are mixed. Not only rooted devices. 35% are Google devices. 45% are Android 8.

Caused by com.getkeepsafe.relinker.MissingLibraryException: Could not find 'librealmc.so'. Looked for: [arm64-v8a, armeabi-v7a, armeabi], but only found: [].
       at com.getkeepsafe.relinker.ApkLibraryInstaller.installLibrary(ApkLibraryInstaller.java:175)
       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.kotlin.internal.AndroidUtilsKt.loadAndroidNativeLibs(AndroidUtils.kt:14)
cmelchior commented 1 year ago

The problem with this error is that we think this is related to the Playstore distribution and App Bundles and sometimes the app store sends the wrong thing to devices. Unfortunately, this is basically impossible to test and we have never been able to reproduce it.

At the same time, we have seen people manually distributing the wrong app bundles to devices, but this normally happens with custom app distribution frameworks or rooted devices where you try to sideload an APK.

That said, we just pushed a change that is available in 1.10-SNAPSHOT which disables Relinker above API 22. The reason we use Relinker is that Android has known bugs loading native code on API 22 and below, but there is no need to use it above.

So just to be 100% sure this library is not involved in these bugs, it has now been disabled.

Apart from that, the solution we have seen working is to disable App Bundles, unfortunately, the tradeoff there is an increase in APK size.

Ynnck123 commented 5 months ago

Are there any updates on this issue or the proposed fix of disabling app bundles? We are also experience this error in one of our production apps.

Devices are for example OnePlus 9 5G with Android 14; Realm Kotlin version currently 1.12.0. Maybe there are fixes in an already released version? The issue is still set to be open therefore I assume it's not fixed yet?

ponvig commented 5 months ago

We are also facing this issue. So far we've seen crashes on Galaxy A14 5G Android 13 and Nexus 5x Android 8.

skauss commented 5 months ago

Same problem on OnePlus 9 Android14, on an Kotlin Multiplatform project. "io.realm.kotlin", name = "library-base" Version = 1.14.0

Caused by androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: dlopen failed: library "librealmc.so" not found
       at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:187)
       at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238)
Caused by java.lang.UnsatisfiedLinkError: dlopen failed: library "librealmc.so" not found
       at java.lang.Runtime.loadLibrary0(Runtime.java:1082)
       at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
       at java.lang.System.loadLibrary(System.java:1661)
       at io.realm.kotlin.internal.AndroidUtilsKt.loadAndroidNativeLibs(AndroidUtils.kt:20)
       at io.realm.kotlin.internal.RealmInitializer.create(RealmInitializer.kt:42)
       at io.realm.kotlin.internal.RealmInitializer.create(RealmInitializer.kt:30)
       at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:180)

Inside my APK

./lib/armeabi-v7a/librealmc.so
./lib/x86/librealmc.so
./lib/arm64-v8a/librealmc.so
./lib/x86_64/librealmc.so
skauss commented 4 months ago

New devices with this error Huawei ALN-AL00, Android 12

Fatal Exception: java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: dlopen failed: library "librealmc.so" not found at android.app.ActivityThread.installProvider(ActivityThread.java:9416) at android.app.ActivityThread.installContentProviders(ActivityThread.java:8919) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:8591) at android.app.ActivityThread.access$2800(ActivityThread.java:313) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2902) at android.os.Handler.dispatchMessage(Handler.java:117)

and

Google, Pixel 6 Pro, Android 12

Fatal Exception: java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: dlopen failed: library "librealmc.so" not found at android.app.ActivityThread.installProvider(ActivityThread.java:7464) at android.app.ActivityThread.installContentProviders(ActivityThread.java:6976) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6747) at android.app.ActivityThread.access$1500(ActivityThread.java:256) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2091)

skauss commented 4 months ago

I created an Google Issue See loginCompleted.

https://issuetracker.google.com/issues/336832619

MSVhora commented 4 months ago

Same problem on OnePlus 6 Android11, Transsion Note 12 Android13, and Oppo Realme Narzo 30 Android12 on an Android project. "io.realm.kotlin", name = "library-base" Version = 1.13.0

Crash occured for 32 times.

Fatal Exception: java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: dlopen failed: library "librealmc.so" not found
       at android.app.ActivityThread.installProvider(ActivityThread.java:7719)
       at android.app.ActivityThread.installContentProviders(ActivityThread.java:7220)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6973)
       at android.app.ActivityThread.-$$Nest$mhandleBindApplication()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2219)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:204)
       at android.os.Looper.loop(Looper.java:291)
       at android.app.ActivityThread.main(ActivityThread.java:8129)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)
Caused by androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: dlopen failed: library "librealmc.so" not found
       at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:187)
       at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238)
       at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206)
       at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45)
       at android.content.ContentProvider.attachInfo(ContentProvider.java:2473)
       at android.content.ContentProvider.attachInfo(ContentProvider.java:2443)
       at android.app.ActivityThread.installProvider(ActivityThread.java:7714)
       at android.app.ActivityThread.installContentProviders(ActivityThread.java:7220)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6973)
       at android.app.ActivityThread.-$$Nest$mhandleBindApplication()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2219)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:204)
       at android.os.Looper.loop(Looper.java:291)
       at android.app.ActivityThread.main(ActivityThread.java:8129)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)
Caused by java.lang.UnsatisfiedLinkError: dlopen failed: library "librealmc.so" not found
       at java.lang.Runtime.loadLibrary0(Runtime.java:1082)
       at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
       at java.lang.System.loadLibrary(System.java:1661)
       at io.realm.kotlin.internal.AndroidUtilsKt.loadAndroidNativeLibs(AndroidUtils.kt:20)
       at io.realm.kotlin.internal.RealmInitializer.create(RealmInitializer.kt:42)
       at io.realm.kotlin.internal.RealmInitializer.create(RealmInitializer.kt:30)
       at androidx.startup.AppInitializer.doInitialize(AppInitializer.java:180)
       at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:238)
       at androidx.startup.AppInitializer.discoverAndInitialize(AppInitializer.java:206)
       at androidx.startup.InitializationProvider.onCreate(InitializationProvider.java:45)
       at android.content.ContentProvider.attachInfo(ContentProvider.java:2473)
       at android.content.ContentProvider.attachInfo(ContentProvider.java:2443)
       at android.app.ActivityThread.installProvider(ActivityThread.java:7714)
       at android.app.ActivityThread.installContentProviders(ActivityThread.java:7220)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6973)
       at android.app.ActivityThread.-$$Nest$mhandleBindApplication()
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2219)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loopOnce(Looper.java:204)
       at android.os.Looper.loop(Looper.java:291)
       at android.app.ActivityThread.main(ActivityThread.java:8129)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)
EranBoudjnah commented 3 weeks ago

Same here on Nexus 5X (Android 8.1.0) and Pixel 6 Pro (Android 12):

Fatal Exception: java.lang.RuntimeException
Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.mitteloupe.bestchoicemaker-7Fa3BCGrKB0oW6s7-m_jcg==/base.apk"],nativeLibraryDirectories=[/data/app/com.mitteloupe.bestchoicemaker-7Fa3BCGrKB0oW6s7-m_jcg==/lib/x86, /system/lib, /vendor/lib]]] couldn't find "librealmc.so"
Caused by androidx.startup.StartupException
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.mitteloupe.bestchoicemaker-7Fa3BCGrKB0oW6s7-m_jcg==/base.apk"],nativeLibraryDirectories=[/data/app/com.mitteloupe.bestchoicemaker-7Fa3BCGrKB0oW6s7-m_jcg==/lib/x86, /system/lib, /vendor/lib]]] couldn't find "librealmc.so"
Caused by java.lang.UnsatisfiedLinkError
dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.mitteloupe.bestchoicemaker-7Fa3BCGrKB0oW6s7-m_jcg==/base.apk"],nativeLibraryDirectories=[/data/app/com.mitteloupe.bestchoicemaker-7Fa3BCGrKB0oW6s7-m_jcg==/lib/x86, /system/lib, /vendor/lib]]] couldn't find "librealmc.so"
Ynnck123 commented 3 weeks ago

The problem with this error is that we think this is related to the Playstore distribution and App Bundles and sometimes the app store sends the wrong thing to devices. Unfortunately, this is basically impossible to test and we have never been able to reproduce it.

At the same time, we have seen people manually distributing the wrong app bundles to devices, but this normally happens with custom app distribution frameworks or rooted devices where you try to sideload an APK.

That said, we just pushed a change that is available in 1.10-SNAPSHOT which disables Relinker above API 22. The reason we use Relinker is that Android has known bugs loading native code on API 22 and below, but there is no need to use it above.

So just to be 100% sure this library is not involved in these bugs, it has now been disabled.

Apart from that, the solution we have seen working is to disable App Bundles, unfortunately, the tradeoff there is an increase in APK size.

Based on this reply, if it's really because of the Play Store Distribution: Maybe the cause is based on users downloading the app's from third party stores and not from the official Play Store and therefore this file is missing on their installations?

Has anyone subscribed to this topic been able to reproduce this issue? I assume that everyone here is just posting the stacktraces from the crash monitoring of their choice

EranBoudjnah commented 3 weeks ago

The problem with this error is that we think this is related to the Playstore distribution and App Bundles and sometimes the app store sends the wrong thing to devices. Unfortunately, this is basically impossible to test and we have never been able to reproduce it. At the same time, we have seen people manually distributing the wrong app bundles to devices, but this normally happens with custom app distribution frameworks or rooted devices where you try to sideload an APK. That said, we just pushed a change that is available in 1.10-SNAPSHOT which disables Relinker above API 22. The reason we use Relinker is that Android has known bugs loading native code on API 22 and below, but there is no need to use it above. So just to be 100% sure this library is not involved in these bugs, it has now been disabled. Apart from that, the solution we have seen working is to disable App Bundles, unfortunately, the tradeoff there is an increase in APK size.

Based on this reply, if it's really because of the Play Store Distribution: Maybe the cause is based on users downloading the app's from third party stores and not from the official Play Store and therefore this file is missing on their installations?

Has anyone subscribed to this topic been able to reproduce this issue? I assume that everyone here is just posting the stacktraces from the crash monitoring of their choice

I've not been able to reproduce it personally but would like to suggest we rule out the third party stores theory: I get the crashes reported within hours of posting a new release, which I only publish to the Play Store. Unless some third party store picks it up immediately, these are Play Store installations.

Also, the ratio of these crashes for me is about 0.1% of my active users. That's not too bad, but it's still frustrating.

I also noticed that Google closed the ticket that was mentioned earlier.

RowanG1 commented 2 weeks ago

I have precisely the same crash, and also Nexus 5X Android 8.1.0. Also cannot re-produce on emulator. Realm version: io.realm.kotlin:library-base:1.16.0