mapbox-gl-native-android icon indicating copy to clipboard operation
mapbox-gl-native-android copied to clipboard

App bundle and UnsatisfiedLinkError

Open tobrun opened this issue 4 years ago • 5 comments

We have received a numerous reports related to

java.lang.UnsatisfiedLinkError: No implementation found for void com.mapbox.mapboxsdk.net.NativeConnectivityListener.initialize()

  • https://github.com/mapbox/mapbox-gl-native-android/issues/149
  • https://github.com/mapbox/mapbox-gl-native-android/issues/277
  • https://github.com/mapbox/mapbox-gl-native-android/issues/208
  • https://github.com/mapbox/mapbox-gl-native-android/issues/111
  • https://github.com/mapbox/mapbox-gl-native-android/issues/320

The Mapbox Maps SDK for Android, isn’t the only library facing this issue as the root cause seems related to the App Bundle format that Google introduced in 2018. There are a couple of hypothesis/solutions from equivalent threads of different Android libraries using native code:

  • https://github.com/facebook/react-native/issues/23764
  • https://github.com/dji-sdk/Mobile-SDK-Android/issues/333
  • https://forum.unity.com/threads/native-method-not-found-com-unity3d-player-unityplayer-nativerestartactivityindicator-v.546271/
  • ..

Potential solution one:

https://github.com/facebook/react-native/issues/23764#issuecomment-530801648

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

Potential solution two:

https://github.com/facebook/react-native/issues/23764#issuecomment-558139269

Android App Bundle has the native libraries uncompressed. You can add the following configuration to your gradle.properties to revert back to compressing:

android.bundle.enableUncompressedNativeLibs=false

I would love to see if someone from the community can try any of the proposed solutions:

cc @mapbox/maps-android

tobrun avatar Jun 03 '20 11:06 tobrun

solution 2 does not work, we see the issue with android.bundle.enableUncompressedNativeLibs = false defined

JRWilding avatar Aug 07 '20 15:08 JRWilding

+1 this is currently forced to revert using APK which results in much larger app footprint

almo-ltoeroek avatar Aug 31 '20 12:08 almo-ltoeroek

We started seeing this issue after updating to v9.5.0

Before that this crash never occurred. We use an aab.

The crash seems to only be happening on Android 24-26 and on Samsung devices.

We use:

override fun attachBaseContext(base: Context) {
    super.attachBaseContext(base)
    SplitCompat.install(this)
}

in our Application, so the install should have all the pieces it needs to run.

eygraber avatar Dec 22 '20 21:12 eygraber

We now see this on all Android versions that we support (24-30) and most popular manufacturers. We call Mapbox.getInstance in an androidx.startup.Initializer (and before that we were calling it from a ContentProvider), and Application.attachBaseContext should be getting run before that, so SplitCompat.install should guarantee that the installation is valid.

The suggested solutions have not helped.

eygraber avatar Feb 01 '21 02:02 eygraber

Still happening on 9.6.1 although it seems like it only happens when initially uploading the aab to the Play Store. Maybe it's an issue in the device farm that Google uses for testing app updates?

eygraber avatar Apr 11 '21 19:04 eygraber