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

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

Closed
moritzzzzz opened this issue Feb 2, 2022 · 64 comments
Labels
bug 🪲 Something isn't working

Comments

@moritzzzzz
Copy link

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 moritzzzzz added the bug 🪲 Something isn't working label Feb 2, 2022
@moritzzzzz moritzzzzz changed the title Sproadic crashes when Mapbox library is loaded: java.lang.UnsatisfiedLinkError at com.mapbox.common.loader.MapboxLibraryLoader.load Sporadic crashes when Mapbox library is loaded: java.lang.UnsatisfiedLinkError at com.mapbox.common.loader.MapboxLibraryLoader.load Feb 2, 2022
@yunikkk
Copy link
Contributor

yunikkk commented Feb 2, 2022

Seems it's the same issue with library loading as mapbox/mapbox-gl-native-android#416

@pf-burak-sinan
Copy link

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")
    }

@norman-kapschefsky
Copy link

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.

@a-h-mzd
Copy link

a-h-mzd commented Feb 6, 2023

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

@PavlosTze
Copy link

Still an issue at 10.11.0.

@alingocab
Copy link

alingocab commented Feb 16, 2023

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

@jush
Copy link
Member

jush commented Feb 17, 2023

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

@alingocab
Copy link

@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.

@jush
Copy link
Member

jush commented Feb 17, 2023

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

@alingocab
Copy link

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
Copy link

@michaelEllisUy
Copy link

michaelEllisUy commented Mar 3, 2023

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

@boiler23
Copy link

boiler23 commented Mar 4, 2023

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

@alingocab
Copy link

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

@foodpoison
Copy link

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

@ChristopherME
Copy link

Same issue here, current version 10.8.0

@LeeQiuuu
Copy link

i have the same problem

@nwilsongme
Copy link

Same here. Has there been any resolution?

@alingocab
Copy link

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...

@matthew-niemann
Copy link

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?

@iamwent
Copy link

iamwent commented Mar 30, 2023

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

@MrTheGood
Copy link

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

@alingocab
Copy link

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.

@iamwent
Copy link

iamwent commented Mar 31, 2023

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

@kiryldz
Copy link
Contributor

kiryldz commented Mar 31, 2023

Could you please check if following helps?

@boiler23
Copy link

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).

@kawan2019
Copy link

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

@leanh128
Copy link

leanh128 commented May 30, 2023

There is similar issue in mapbox/mapbox-android-demo#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'
}

@tasomaniac
Copy link

That's a good point

@jush
Copy link
Member

jush commented Nov 15, 2023

The Mapbox team has prepared a snapshot with a potential solution for the sporadic crash in the Maps SDK for Android library.

We have been investigating the sporadic crash in the Mapbox library and we have prepared a snapshot with a potential solution for you to test.

While we are confident that this snapshot will help to resolve the issue, we have not been able to reproduce it in our environments, therefore we cannot guarantee that it will be a complete fix. We encourage you to test the snapshot thoroughly and report any issues you find on this issue tracker: #1109.

Your feedback will help us determine the effectiveness of the snapshot and identify any remaining issues.

Instructions for testing the snapshot:

  1. Your app must not be using any other Mapbox SDK (e.g. Navigation, Search).
  2. Install the snapshot maven repository into your project by following the instructions at Use snapshot releases in your app.
  3. Replace your Mapbox SDK for Android version with version 10.16.2-SNAPSHOT.1115T1113Z.912f916.
  4. Run your app and test the functionality.
  5. Publish your app to your users.
  6. Report any issues you find on the issue tracker: Sporadic crashes when Mapbox library is loaded: java.lang.UnsatisfiedLinkError at com.mapbox.common.loader.MapboxLibraryLoader.load #1109.
  7. We appreciate your cooperation as we work to resolve this issue. Thank you for your patience and understanding.

@paul-wag
Copy link

@jush thank you for providing the update. Just wanted to let you know we have an app that only uses search/autocomplete and the issue happens to us. It's one of our top crashes.

Your app must not be using any other Mapbox SDK (e.g. Navigation, Search).

@tasomaniac
Copy link

Thanks for the update. We do use the Navigation dependency. So I guess we will have to wait until this makes it to the stable release

@guitabalipa
Copy link

@jush Do you have an estimate date for this fix to hit the stable version?

@AndroidPat
Copy link

The Mapbox team has prepared a snapshot with a potential solution for the sporadic crash in the Maps SDK for Android library.

We have been investigating the sporadic crash in the Mapbox library and we have prepared a snapshot with a potential solution for you to test.

While we are confident that this snapshot will help to resolve the issue, we have not been able to reproduce it in our environments, therefore we cannot guarantee that it will be a complete fix. We encourage you to test the snapshot thoroughly and report any issues you find on this issue tracker: #1109.

Your feedback will help us determine the effectiveness of the snapshot and identify any remaining issues.

Instructions for testing the snapshot:

  1. Your app must not be using any other Mapbox SDK (e.g. Navigation, Search).
  2. Install the snapshot maven repository into your project by following the instructions at Use snapshot releases in your app.
  3. Replace your Mapbox SDK for Android version with version 10.16.2-SNAPSHOT.1115T1113Z.912f916.
  4. Run your app and test the functionality.
  5. Publish your app to your users.
  6. Report any issues you find on the issue tracker: Sporadic crashes when Mapbox library is loaded: java.lang.UnsatisfiedLinkError at com.mapbox.common.loader.MapboxLibraryLoader.load #1109.
  7. We appreciate your cooperation as we work to resolve this issue. Thank you for your patience and understanding.

Thanks for trying to resolve it. It's a #1 crash in our app. I've tried pulling 10.16.2-SNAPSHOT.1115T1113Z.912f916 but I get 403 forbidden error. The version 10.16.2 pulls fine.

@kiryldz
Copy link
Contributor

kiryldz commented Nov 28, 2023

@AndroidPat
Please make sure you have added the additional Maven mirror as described in the point 2 in the instructions.

@AndroidPat
Copy link

@AndroidPat Please make sure you have added the additional Maven mirror as described in the point 2 in the instructions.

Thank you, I missed this bit!
I've changed the URL to the snapshot one and the error changed from https://mvnrepository.com/artifact/com.github.gundy/semver4j/com/mapbox/plugin/maps-lifecycle/10.16.2-SNAPSHOT.1115T1113Z.912f916/maps-lifecycle-10.16.2-SNAPSHOT.1115T1113Z.912f916.pom

to

Could not HEAD 'https://mvnrepository.com/artifact/com.github.gundy/semver4j/com/mapbox/base/common/0.8.0/common-0.8.0.pom'. Received status code 403 from server: Forbidden

@kiryldz
Copy link
Contributor

kiryldz commented Nov 29, 2023

@AndroidPat Please make sure you have added the additional Maven mirror as described in the point 2 in the instructions.

Thank you, I missed this bit! I've changed the URL to the snapshot one and the error changed from https://mvnrepository.com/artifact/com.github.gundy/semver4j/com/mapbox/plugin/maps-lifecycle/10.16.2-SNAPSHOT.1115T1113Z.912f916/maps-lifecycle-10.16.2-SNAPSHOT.1115T1113Z.912f916.pom

to

Could not HEAD 'https://mvnrepository.com/artifact/com.github.gundy/semver4j/com/mapbox/base/common/0.8.0/common-0.8.0.pom'. Received status code 403 from server: Forbidden

@AndroidPat please add the new mirror and do not replace it. Your gradle file should look somehow like:

allprojects {
    repositories {
        // your staff
        maven {
            url 'https://api.mapbox.com/downloads/v2/releases/maven'
            authentication {
                basic(BasicAuthentication)
            }
            credentials {
                username = "mapbox"
                password = YOUR_SECRET_TOKEN
            }
        }
        maven {
            url 'https://api.mapbox.com/downloads/v2/snapshots/maven'
            authentication {
                basic(BasicAuthentication)
            }
            credentials {
                username = "mapbox"
                password = YOUR_SECRET_TOKEN
            }
        }
    }
}

@AndroidPat
Copy link

https://gist.github.com/AndroidPat/173e70244bf05c386745bdd70398ec9c
No luck, I've tried changing the order and invalidating caches etc.
If you have any ideas, I would appreciate a comment on the gist, to keep this thread clean.

@kiryldz
Copy link
Contributor

kiryldz commented Dec 8, 2023

The fix with the same limitations regarding Mapbox Navigation SDK and Mapbox Search SDK as was described in #1109 (comment) has been included in https://github.com/mapbox/mapbox-maps-android/releases/tag/v10.16.3. We will continue on pushing the fix to Maps v11 / Navigation / Search to fully eliminate the issue across all the Mapbox Android SDKs and post updates here.

@oguzcelik
Copy link

Hey folks 🖖 We are planning to test the new 10.16.3 version to resolve the crash. But we are using the nav sdk for some of our applications https://github.com/mapbox/mapbox-navigation-android/releases/tag/v2.17.2

In the release notes for the version it mentions that if we use nav sdk, we might still face the crash. And in the nav sdk release notes it mentions the version is tested with an earlier version.

I have 2 questions to clear some confusions we have.

  • Does it mean that we will continue to have the crash that we discussed in the thread, or could there be more incompatibility with the nav sdk version we use and the fix in 10.16.3 ?
  • Do you have a plan/estimate on when the nav sdk would have this fix as well ?

Thank you for providing a fix for this issue. It's been a long time that we had this as a top crash 🚀

@kiryldz
Copy link
Contributor

kiryldz commented Dec 11, 2023

Hey @oguzcelik!

Does it mean that we will continue to have the crash that we discussed in the thread, or could there be more incompatibility with the nav sdk version we use and the fix in 10.16.3 ?

You will most likely see another crash saying that another (navigation related and not common described in this issue) .so native library could not be loaded. Also noting that using Nav SDK 2.17.2 with Maps 10.16.3 will most likely crash in runtime due to different native symbols. To be on the safe side Nav SDK should release another patch that's compatible with Maps 10.16.3.

Do you have a plan/estimate on when the nav sdk would have this fix as well ?

No clear estimations for now sadly. As soon as we have details we will share them here. The high level plan is to actually have the fix in Maps v11 first thing and then focus on updating Nav / Search SDKs.

@felixkrautschuk
Copy link

I just tred out the latest version com.mapbox.maps:android:11.2.0-beta.1
but the app is still crashing on start:

Caused by: com.mapbox.common.MapboxInitializerException: Failed to initialize: Attempt=2, exception=[StartupException], initializer called 3686 ms ago, exception.message=[androidx.startup.StartupException: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/data/app/~~QOSaTqLzwRmrFoH4QDBnDw==/de.maxity.mapbox.demo-7HnSklBqHWjkhF9tDLs1Xw==/base.apk!/lib/x86_64/libmapbox-common.so"...], exception.cause=[StartupException], exception.cause.message=[java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/data/app/~~QOSaTqLzwRmrFoH4QDBnDw==/de.maxity.mapbox.demo-7HnSklBqHWjkhF9tDLs1Xw==/base.apk!/lib/x86_64/libmapbox-common.so"...], extractedNativeLibs=[], isInstantApp=[false], isMainThread=[true]

@jush
Copy link
Member

jush commented Feb 1, 2024

@felixkrautschuk Hi, this seems slightly different issue. This is not that the native library is completely missing in the device but rather that __emutls_get_address symbol can't be found.

Most likely you're mixing different Mapbox SDKs (e.g., Maps SDK with Search SDK, or Navigation SDK) versions and that causes some issues for commonly shared code among those.

Could you please share more details about:

  1. share detailed steps how to reproduce? if possible also repro project.
  2. Your setup, what dependencies do you have in the project?
  3. Device details where the issue is happening (model, OS version,...)

Actually, might be even better to open a new ticket.

Thanks!

@felixkrautschuk
Copy link

@jush thanks for your response.

I created a new ticket here: #2271

@kiryldz
Copy link
Contributor

kiryldz commented Mar 25, 2024

Hey all, Mapbox has implemented better way of initialization and it's available both for Maps v10 / v11 and Nav v2 / v3.

Here's the list of actual versions where this is implemented:

  1. Nav 2.19.0 that uses Maps v10.16.6.
  2. Core Framework v1.0.0-rc.3 that uses Maps v11.2.0.

What does the fix cover

This means that exception described in this ticket happening on startup (as we're using AndroidX initializers in SDK) should not happen anymore. However we did not find the actual root cause why the native libraries might be missing on startup, it seems to be the Android App Bundle implementation which is out of our control.

So the initialization workflow now works the following way:

  1. We initialize as we did before using AndroidX initializers.
  2. If initialization attempt on app startup failed we gracefully switch to "lazy" initialization. This means that Mapbox will initialize only when any actual Mapbox API will be called. We assume that the most common use-case is actually creating / inflating the MapView somewhere in activity / fragment so in that example it means that if we failed to load native libraries on startup, the SDK will handle this for you and try to run all the initialization code right before creating the MapView.

Summing up: the UnsatisfiedLinkError should be eliminated without any changes in client code. The similar approach was proved to be working at least by @boiler23 in this comment so we hope it should help other users as well. P.S if you had #1109 (comment) workaround implemented - it should be reverted when switching to the Maps / Nav versions that contain the fix.

What does the fix not cover

As said above we did not find the actual reason why the native libraries might not be in place. So it's absolutely possible that even if we gracefully catch the exception for you on startup and do not crash - the libraries might still be not there when you first access the Mapbox APIs. The most obvious use-case for that is accessing some Mapbox APIs in your Application.onCreate which is actually triggered shortly after AndroidX initializers are run and there's high chance that the native libraries are still not there.

If the native libraries could not be loaded right before Mapbox function - our SDK could not work. However with that new approach it's still possible to recover in this situation but that will require adding code in your end applications based on the business logic you want to apply.

Example: You have an app that uses App Bundle and even after upgrading to latest version with a fix you see crashes (hopefully reduced amount). Looking into your code you realize that the MapView is shown right after entering your application in the first Activity.

// somewhere in your Activity.onCreate
val mapView = MapView(this)

In that case you could apply the following approach:

try {
  // if Mapbox was actually init successfully before - this call is no-op and cancels immediately;
  // if Mapbox was not init due to missing native libraries - we will try to initialize again
  // this thing could throw an exception if native libraries are not found
  BaseMapboxInitializer.init(MapboxSDKCommonInitializerImpl.class)
  // if we are hitting this line we could safely assume that initialization was fine and we could proceed
  val mapView = MapView(this)
} catch (e: Throwable) {
   // for example you could either some UI with `Retry` button and clicking that button runs this code again;
   // or you could ask the user try re-opening the application
   // or do something else based no your business needs
}

Conclusion

We hope that the fix will work well for you. I am closing this ticket (as it's already way too huge) but please feel free to open new issues (also note that we greatly enhanced the underlying exception so it contains additional data that might help us to proceed even further hopefully in fully eliminating this in SDK). As an example there was already an issue related to new approach and connected with accessing Mapbox API inside user's initializers.

@kiryldz kiryldz closed this as completed Mar 25, 2024
@PavlosTze
Copy link

PavlosTze commented Mar 26, 2024

@kiryldz But we cannot upgrade Mapbox because of this.

@dudeuter
Copy link

dudeuter commented May 2, 2024

@PavlosTze the issue you shared is different from the one in this thread. I added some notes on your issue for anyone who's poking around.

This issue is for java.lang.UnsatisfiedLinkError at com.mapbox.common.loader.MapboxLibraryLoader.load which is related to the SDK's initializers being run.

For anyone getting the error from this thread the best trouble shooting steps will be:

  1. Look in your build intermediates folder to make sure your merged AndroidManifest has entries for the Mapbox Initializers.
  2. Make sure that your application is packaging the shared objects as expected

Some useful shell commands, run from your project directory.

find ./app/build -type f -name "*.so"

You should see some mapbox shared objects in your build intermediates. Additionally you can unpack your applications APK file to look for the shared objects as well.

grep --binary-files=without-match -Rin "initializer" ./app/build

You should see an entries for a mapbox initializer; if it's omitted then there's something about your app's android manifest that's overriding the SDK's manifest to run the initializer; which loads the shared objects. This also should be in the APK as well.

@PavlosTze
Copy link

PavlosTze commented May 16, 2024

@dudeuter I ran find ./app/build -type f -name "*.so", I got the following files:

./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/arm64-v8a/libc++_shared.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/arm64-v8a/libmapbox-common.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/arm64-v8a/libmapbox-maps.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/arm64-v8a/libSearchCore.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/armeabi-v7a/libc++_shared.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/armeabi-v7a/libmapbox-common.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/armeabi-v7a/libmapbox-maps.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/armeabi-v7a/libSearchCore.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/x86/libc++_shared.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/x86/libmapbox-common.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/x86/libmapbox-maps.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/x86/libSearchCore.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/x86_64/libc++_shared.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/x86_64/libmapbox-common.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/x86_64/libmapbox-maps.so
./app/build/intermediates/stripped_native_libs/remoteProdDebug/stripRemoteProdDebugDebugSymbols/out/lib/x86_64/libSearchCore.so

But we still get the following crash in our users (on Nexus 5X) in that version:

Fatal Exception: java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: F2.e: F2.e: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.weatherxm.app-WtWVlz_qUWeQ6Gxy2BFgqA==/base.apk"],nativeLibraryDirectories=[/data/app/com.weatherxm.app-WtWVlz_qUWeQ6Gxy2BFgqA==/lib/x86, /system/lib, /vendor/lib]]] couldn't find "libSearchCore.so"

@dudeuter
Copy link

@PavlosTze can you confirm that you have the initializer as well? Lastly you can repeat the step above by unpacking your apk as well.

If everything there still exists then it's likely a conflict with how you have Multidexing configured; which is more of an Android issue that a Mapbox issue.

@PavlosTze
Copy link

@dudeuter I confirm that we have the initializer and we have the libraries in the APK as well, everything is there.

We don't have Multidexing configured, and these crashes did not take place for years until since the version mentioned in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests