mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

Sporadic crashes when Mapbox library is loaded: java.lang.UnsatisfiedLinkError at com.mapbox.common.loader.MapboxLibraryLoader.load

Open moritzzzzz opened this issue 3 years ago • 1 comments

Environment

  • Android OS version: Android 11
  • Devices affected: 83% Samsung, 17% Google
  • Maps SDK Version:
implementation "com.mapbox.maps:android:10.1.0"
implementation "com.mapbox.mapboxsdk:mapbox-sdk-turf:5.8.0"

Observed behavior and steps to reproduce

Sporadic crashes reported via crashlytics when loading Mapbox libraries.

Expected behavior

No crashes.

Notes / preliminary analysis

Additional links and references

Stack trace

java.lang.RuntimeException: 
  at android.app.ActivityThread.installProvider (ActivityThread.java:7769)
  at android.app.ActivityThread.installContentProviders (ActivityThread.java:7309)
  at android.app.ActivityThread.handleMakeApplication (ActivityThread.java:7166)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7134)
  at android.app.ActivityThread.access$1500 (ActivityThread.java:274)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2102)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:237)
  at android.app.ActivityThread.main (ActivityThread.java:8167)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)
Caused by: androidx.startup.StartupException: 
  at androidx.startup.AppInitializer.doInitialize (AppInitializer.java:162)
  at androidx.startup.AppInitializer.discoverAndInitialize (AppInitializer.java:198)
  at androidx.startup.InitializationProvider.onCreate (InitializationProvider.java:38)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2113)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2087)
  at android.app.ActivityThread.installProvider (ActivityThread.java:7764)
  at android.app.ActivityThread.installContentProviders (ActivityThread.java:7309)
  at android.app.ActivityThread.handleMakeApplication (ActivityThread.java:7166)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7134)
  at android.app.ActivityThread.access$1500 (ActivityThread.java:274)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2102)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:237)
  at android.app.ActivityThread.main (ActivityThread.java:8167)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)
Caused by: java.lang.UnsatisfiedLinkError: 
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1067)
  at java.lang.Runtime.loadLibrary0 (Runtime.java:1007)
  at java.lang.System.loadLibrary (System.java:1667)
  at com.mapbox.common.loader.MapboxLibraryLoader.load (MapboxLibraryLoader.kt:19)
  at com.mapbox.common.MapboxSDKCommonInitializer.create (MapboxSDKCommonInitializer.kt:62)
  at com.mapbox.common.MapboxSDKCommonInitializer.create (MapboxSDKCommonInitializer.kt:11)
  at androidx.startup.AppInitializer.doInitialize (AppInitializer.java:155)
  at androidx.startup.AppInitializer.discoverAndInitialize (AppInitializer.java:198)
  at androidx.startup.InitializationProvider.onCreate (InitializationProvider.java:38)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2113)
  at android.content.ContentProvider.attachInfo (ContentProvider.java:2087)
  at android.app.ActivityThread.installProvider (ActivityThread.java:7764)
  at android.app.ActivityThread.installContentProviders (ActivityThread.java:7309)
  at android.app.ActivityThread.handleMakeApplication (ActivityThread.java:7166)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:7134)
  at android.app.ActivityThread.access$1500 (ActivityThread.java:274)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2102)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:237)
  at android.app.ActivityThread.main (ActivityThread.java:8167)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)

moritzzzzz avatar Feb 02 '22 09:02 moritzzzzz

Seems it's the same issue with library loading as https://github.com/mapbox/mapbox-gl-native-android/issues/416

yunikkk avatar Feb 02 '22 11:02 yunikkk

We've started to get this exception lately as well. Here are the details, I hope it helps: Stack trace:

java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: androidx.startup.StartupException: androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/package-name-VCfnYXvvcgeoxfVicOChTA==/base.apk"],nativeLibraryDirectories=[/data/app/package-name-VCfnYXvvcgeoxfVicOChTA==/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libmapbox-common.so"
at android.app.ActivityThread.installProvider(ActivityThread.java:6242)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5805)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5722)
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/package-name-VCfnYXvvcgeoxfVicOChTA==/base.apk"],nativeLibraryDirectories=[/data/app/package-name-VCfnYXvvcgeoxfVicOChTA==/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libmapbox-common.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:1011)
at java.lang.System.loadLibrary(System.java:1657)
at com.mapbox.common.loader.MapboxLibraryLoader.load(MapboxLibraryLoader.kt:6)
at com.mapbox.common.CoreInitializer.create(CoreInitializer.kt:2)
at com.mapbox.common.CoreInitializer.create(CoreInitializer.kt:1)
at wj.b(AppInitializer.java:88)
... 17 more

So far we faced this issue on 2 devices repeatedly:

  • Android 8.1.0; Nexus 5X on January 23
  • Android 7.1.2; SM-T555 on January 18

Dependency details:

implementation("com.mapbox.maps:android:10.10.0") {
        exclude(group = "com.mapbox.plugin", module = "maps-compass")
        exclude(group = "com.mapbox.plugin", module = "maps-attribution")
        exclude(group = "com.mapbox.plugin", module = "maps-scalebar")
        exclude(group = "com.mapbox.plugin", module = "maps-overlay")
        exclude(group = "com.mapbox.plugin", module = "maps-locationcomponent")
        exclude(group = "com.mapbox.plugin", module = "maps-viewport")
    }

pf-burak-sinan avatar Jan 23 '23 13:01 pf-burak-sinan

Also spiking for us now rapidly from today on:

Fatal Exception: java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: dlopen failed: library "libmapbox-common.so" not found
       at android.app.ActivityThread.installProvider(ActivityThread.java:8215)
       at android.app.ActivityThread.installContentProviders(ActivityThread.java:7746)
       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7566)
       at android.app.ActivityThread.access$1500(ActivityThread.java:301)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2177)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8653)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

~80% of that crash are on Android 11 where 80% is Samsung Galaxy A12 atm. We use mapbox 10.6.0.

norman-kapschefsky avatar Jan 31 '23 12:01 norman-kapschefsky

We're getting the same error and we use mapbox 10.10.0.

a-h-mzd avatar Feb 06 '23 10:02 a-h-mzd

Still an issue at 10.11.0.

PavlosTze avatar Feb 15 '23 15:02 PavlosTze

Hi! I'm getting this error more and more often. Yesterday I pushed an update to users and it started to happen even more often than before. Please see the image.

I'm using these Mapbox dependencies:

com.mapbox.mapboxsdk:mapbox-sdk-services:6.10.0 com.mapbox.maps:android:10.10.1

Screenshot 2023-02-16 at 09 24 37

Screenshot 2023-02-16 at 09 24 32

Screenshot 2023-02-16

alingocab avatar Feb 16 '23 07:02 alingocab

@alingocab Have you released an app with crashlytics 18.3.0 (or higher) recently?

jush avatar Feb 17 '23 07:02 jush

@jush I'm using com.google.firebase:firebase-bom:31.2.1. As I can see, firebase-bom:31.2.1 is using crashlytics 18.3.5.

alingocab avatar Feb 17 '23 08:02 alingocab

Thanks, Crashlytics release 18.3.0 introduced this change that might explain why you see it more often:

Improved crash reporting reliability for crashes that occur early in the app's lifecycle

jush avatar Feb 17 '23 08:02 jush

Ok. It is very good that I can see it, but the main issue is that the app is actually crashing with this error. I can see a huge number of crashes generated by some of the devices like Nexus 5x, Samsung Galaxy S9+ etc.

Screenshot 2023-02-17 at 10 13 17

alingocab avatar Feb 17 '23 08:02 alingocab

Same issue here as well. Crash log looks just like the one posted by alingocab as well as the OP.

michaelEllisUy avatar Mar 03 '23 02:03 michaelEllisUy

I also observe these crashes after migrating from v9 to v10.

boiler23 avatar Mar 04 '23 10:03 boiler23

Hello. Yesterday we updated com.mapbox.maps:android to 10.11.1. Still, those crashes started to flow immediately after update. Please see the screenshot attached. It would be very helpful if someone from Mapbox team can provide a solution to this. This thread has been started more than 1 year ago and still no practical response. Thanks in advance. Screenshot 2023-03-09 at 11 16 11

alingocab avatar Mar 09 '23 09:03 alingocab

Same issue here as well after the v9 ->v10 migration, currently on v10.11.1

foodpoison avatar Mar 09 '23 22:03 foodpoison

Same issue here, current version 10.8.0

ChristopherME avatar Mar 16 '23 14:03 ChristopherME

i have the same problem

LeeQiuuu avatar Mar 22 '23 06:03 LeeQiuuu

Same here. Has there been any resolution?

nwilsongme avatar Mar 23 '23 01:03 nwilsongme

Update mabox sdk to 10.12.0 today, issue still present, a lot of crashes coming up. Seems like this crash is not important for mapbox team...

alingocab avatar Mar 27 '23 14:03 alingocab

Also seeing this issue since using Crashlytics 18.3.0+, but I have not physically seen the crash myself, nor have I received a "startup crash" report from our beta testers or Play Store users. Perhaps it is either a 'silent' crash, or happens only once per user and they assume nothing of it?

matthew-niemann avatar Mar 29 '23 07:03 matthew-niemann

I have the same crash with device Nexus 5X 8.1.0 while Mapbox Android is 10.12.0

iamwent avatar Mar 30 '23 05:03 iamwent

I have the same crash with device Nexus 5X 8.1.0 while Mapbox Android is 10.12.0

For me this is the same: while there are only 3 users having this crash, they're all on a Nexus 5x with Android 8.1.0

MrTheGood avatar Mar 30 '23 09:03 MrTheGood

I have the same crash with device Nexus 5X 8.1.0 while Mapbox Android is 10.12.0

For me this is the same: while there are only 3 users having this crash, they're all on a Nexus 5x with Android 8.1.0

The reason you see Nexus 5x is because that's a device used by Google to run some tests on your app before pushing it to Google Play. In my case, beside this Nexus 5x I see a lot of other devices owned by real users.

alingocab avatar Mar 30 '23 09:03 alingocab

It's interesting. But there are also some crashes on the Galaxy devices.

iamwent avatar Mar 31 '23 08:03 iamwent

Could you please check if following helps?

kiryldz avatar Mar 31 '23 13:03 kiryldz

In my case I don't remove any initialization providers, so the solution above won't help I believe. Merged manifest file also looks fine IMO:

<provider
    android:name="androidx.startup.InitializationProvider"
    android:authorities="com.myapp.androidx-startup"
    android:exported="false" >
    <meta-data
        android:name="com.mapbox.maps.loader.MapboxMapsInitializer"
        android:value="androidx.startup" />
    <!-- This entry makes MapboxSDKCommonInitializer discoverable. -->
    <meta-data
        android:name="com.mapbox.common.MapboxSDKCommonInitializer"
        android:value="androidx.startup" />
    <meta-data
        android:name="androidx.emoji2.text.EmojiCompatInitializer"
        android:value="androidx.startup" />
    <meta-data
        android:name="androidx.lifecycle.ProcessLifecycleInitializer"
        android:value="androidx.startup" />
</provider>

I still didn't receive any complaints from users, and most of the cases happen in the background: screenshot

Maybe this will give you some clues for investigation: I have two separate processes in the app. So the hypothesis is this initialization issue happens in the second process, which doesn't interact with Mapbox and doesn't provide any UI (and that's probably why there are no complaints from users).

boiler23 avatar Apr 12 '23 17:04 boiler23

Still an issue at 10.12.2 Screen Shot 2023-04-23 at 12 14 36 PM

kawan2019 avatar Apr 23 '23 09:04 kawan2019

There is similar issue in https://github.com/mapbox/mapbox-android-demo/issues/1280

we can add these config into app's build.gradle

packagingOptions {
  pickFirst '/armeabi-v7a/libmapbox-common.so'
  pickFirst '/x86/libmapbox-common.so'
  pickFirst '/arm64-v8a/libmapbox-common.so'
  pickFirst '/x86_64/libmapbox-common.so'
  pickFirst '**/x86/libmapbox-common.so'
}

leanh128 avatar May 30 '23 15:05 leanh128

Could you please check if following helps?

The above workaround initially made a lot of sense to us but unfortunately it did not work for us. After applying this, the stack trace has changed. Now we can see that the initialization is explicitly called within our Application class but immediately after that the app crashes with the same reason.

tasomaniac avatar May 31 '23 09:05 tasomaniac

Unfortunately, solution from @leanh128 didn't help me either. Currently using 10.14.0-beta.1.

boiler23 avatar Jun 07 '23 20:06 boiler23