Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

[Android] couldn't find "libbugsnag-ndk.so" #369

Closed
tgensol opened this issue Jun 17, 2019 · 22 comments
Closed

[Android] couldn't find "libbugsnag-ndk.so" #369

tgensol opened this issue Jun 17, 2019 · 22 comments

Comments

@tgensol
Copy link

tgensol commented Jun 17, 2019

Description

I upgraded Bugsnag-react-native to the latest version, and some users are getting crash when they tried to open the app. I am getting an error in bugsnag :

java.lang.UnsatisfiedLinkErrorMainApplication.java:146

What did I miss in the configuration ? I am using RN 0.59 with gradle 5.4.1 and useAndroidX set to true.

Thanking you in advance,
Regards

Issue

java.lang.UnsatisfiedLinkError · dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.appchoose.choose.android-1/base.apk"],nativeLibraryDirectories=[/data/app/com.appchoose.choose.android-1/lib/arm64, /system/lib64, /vendor/lib64]]] couldn't find "libbugsnag-ndk.so"

Environment

  • simulator/emulator or physical device?: Physical

  • debug mode or production?: production

  • [X ] (Android only) BugsnagReactNative.start(this) is present in the
    onCreate method of your MainApplication class?

Error messages: ava.lang.UnsatisfiedLinkError · dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.appchoose.choose.android-1/base.apk"],nativeLibraryDirectories=[/data/app/com.appchoose.choose.android-1/lib/arm64, /system/lib64, /vendor/lib64]]] couldn't find "libbugsnag-ndk.so"
@kattrali
Copy link
Contributor

Thanks for the report, @tgensol. What version of Android is on the device?

@tgensol
Copy link
Author

tgensol commented Jun 17, 2019

I have errors with :
5.0.2 (XT320)
7.1.1 (samsung SM-G930F)
7.1.2 (Pixel)
9 (ONEPLUS A6003)

@fractalwrench
Copy link
Contributor

Hi @tgensol - I've tried following the integration instructions in our examples/plain sample app in this project and wasn't able to reproduce this behaviour on a Nexus 4 running API 22. I'm using bugsnag-react-native v2.21.0, v4.4.0 of the bugsnag gradle plugin, and gradle 4.10.2.

I also decompiled the APK using Android Studio's APK analyzer which confirmed that the SO files are in the lib directory of the APK. Would you be able to confirm whether you can reproduce this behaviour consistently, or whether your app differs from this setup at all?

If your app uses APK splits or App Bundles that would also be very useful to know, and particularly what architectures you build for if so. This error can sometimes be caused by users side-loading an APK split which is the wrong architecture for their device, so it'd be good to rule that out.

@tgensol
Copy link
Author

tgensol commented Jun 18, 2019

Hi @fractalwrench ,
Thanks for your help ! I also tried myself to reproduce it, but I cannot... It only happens on ~50 users (over thousands of users),

  • I am using gradle 5.4.1
  • I am using App Bundles

Maybe my build.gradle file is mis-configured ?

I am using

  ndk {
            abiFilters  "armeabi-v7a", "x86", "arm64-v8a", "x86-64"
        }
and 

splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86-64"
        }
    }

whereas in your examples you are using :

        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86"
        }
    }

I will put an example of error I got today :

batteryLevel   0.4 
brand   samsung
charging false
cpuAbi  [
  "armeabi-v7a",
  "armeabi"
]
dpi 420
emulator false
freeDisk 11679260672
freeMemory 125098104
manufacturer  samsung
model SM-A510F
networkAccess cellular
orientation portrait
osName android
osVersion 7.0
runtimeVersions {
  "osBuild": "NRD90M.A510FXXU8CSC3",
  "androidApiLevel": "24"
}

Uploading bugsnag_error_stacktrace_java.lang.UnsatisfiedLinkError_event_5d079e9100441e60ec760000.txt…

Best regards

@fractalwrench
Copy link
Contributor

Hi @tgensol - your build.gradle seems configured correctly. If you're using App Bundles then sometimes this can result in an UnsatisfiedLinkError if a user side-loads an APK with the wrong architecture, as no native library will be found by Android. Keepsafe wrote a great post explaining this in more detail here.

Would you be able to send in a URL of an UnsatisfiedLinkError from your bugsnag dashboard to support@bugsnag.com, and a link to this issue for context? I'll then be able to view additional information that's available in the error report, which might reveal whether this is a different issue from APK side-loading.

@pqkluan
Copy link

pqkluan commented Jul 30, 2019

Hi @fractalwrench , our app also encountered this issue. Here is the issue link to our dashboard.

@mattdyoung
Copy link

Hi @pqkluan

We've taken a look at your error and the occurrences fall into two cases.

  1. Error message: ... couldn't find "libbugsnag-ndk.so"
    We believe this error is due to users side-loading an APK split generated from an App Bundle which is the wrong architecture for their device. Keepsafe wrote a great blog post where they found similar behaviour was caused by users downloading the wrong APK from a 3rd party source.

  2. Error message: dlopen failed: couldn't map "/.../split_config.arm64_v8a.apk!/lib/arm64-v8a/libbugsnag-ndk.so" segment 0: Permission denied
    Another customer was able to reproduce this error by installing from an APK built from an App Bundle using Google Play and moving the app to SD card storage. They found the issue went away when they downgraded Android Gradle Plugin to 3.2. We believe this is likely an issue with Android Gradle Plugin as even removing the Bugsnag library, they found the issue persisted with a different native library.

@pqkluan
Copy link

pqkluan commented Aug 7, 2019

Hi, @mattdyoung Thanks for the advice, but I don't think the 1st theory is possible since there are more than 150 users affected by this issue, and there shouldn't be not that much people willing to manually install our app outside of PlayStore.

For the 2nd one, downgrading the Android Gradle Plugin is also not a possible solution for us since there are other dependencies require newer gradle version.

@mattdyoung
Copy link

Hi @pqkluan

Regarding 1, roughly what percentage of your userbase are the 150 users? Are you seeing this only on particular devices?

For 2, there is very little we can do as this is an issue with Android Gradle Plugin:
https://issuetracker.google.com/issues/127691101

That thread suggested that using android.bundle.enableUncompressedNativeLibs=false should work around the issue.

@ben-j69
Copy link

ben-j69 commented Aug 21, 2019

I encounter the same error on my dev build since Android Studio 3.5 and gradle update and migration to AndroidX with bugsnag 4.16

@abigailbramble
Copy link

@ben-j69 thanks for your comment. I don't know if you saw @mattdyoung response above?

Another customer was able to reproduce this error by installing from an APK built from an App Bundle using Google Play and moving the app to SD card storage. They found the issue went away when they downgraded Android Gradle Plugin to 3.2. We believe this is likely an issue with Android Gradle Plugin as even removing the Bugsnag library, they found the issue persisted with a different native library.

@benoitdion
Copy link

seeing the same issue as @ben-j69 with 2.23.1, it did not reproduce on 2.22.4

@benoitdion
Copy link

benoitdion commented Sep 9, 2019

@mattdyoung
Copy link

Hi @benoitdion

Which error are you seeing?

Is it one of the errors referred to in my previous response here?
#369 (comment)

Or something different?

Would you be able to write in to support@bugsnag.com with a link to the related error in your Bugsnag dashboard so we can examine the full stacktrace and see if we can identify the cause?

@khonkaengame
Copy link

khonkaengame commented Sep 23, 2019

I have same issue on version v4.6.5.

@mattdyoung
Copy link

@khonkaengame
Are you seeing one of the 2 errors described in my previous response here?
#369 (comment)

Also v4.6.5 of which library?

@khonkaengame
Copy link

khonkaengame commented Sep 28, 2019 via email

@abigailbramble
Copy link

@khonkaengame are you able to say which of the errors you are seeing?
Are you getting
Error message: ... couldn't find "libbugsnag-ndk.so"
or
Error message: dlopen failed: couldn't map "/.../split_config.arm64_v8a.apk!/lib/arm64-v8a/libbugsnag-ndk.so" segment 0: Permission denied

@khonkaengame
Copy link

khonkaengame commented Oct 5, 2019

@abigail-bugsnag
I am getting couldn't find "libbugsnag-ndk.so"

Here is full error :
10-05 08:41:33.722 19038 19066 E Unity : AndroidJavaException: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.khonkaengame.hiloprofessional-1/base.apk", zip file "/data/app/com.khonkaengame.hiloprofessional-1/split_config.arm64_v8a.apk"],nativeLibraryDirectories=[/data/app/com.khonkaengame.hiloprofessional-1/lib/arm64, /data/app/com.khonkaengame.hiloprofessional-1/base.apk!/lib/arm64-v8a, /data/app/com.khonkaengame.hiloprofessional-1/split_config.arm64_v8a.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libbugsnag-ndk.so"10-05 08:41:33.722 19038 19066 E Unity : java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.khonkaengame.hiloprofessional-1/base.apk", zip file "/data/app/com.khonkaengame.hiloprofessional-1/split_config.arm64_v8a.apk"],nativeLibraryDirectories=[/data/app/com.khonkaengame.hiloprofessional-1/lib/arm64, /data/app/com.khonkaengame.hiloprofessional-1/base.apk!/lib/arm64-v8a, /data/app/com.khonkaengame.hiloprofessional-1/split_config.arm64_v8a.apk!/lib/arm64-

More detail, I build by select on build app bundle(google play).

@mattdyoung
Copy link

Hi @khonkaengame

We've seen this error caused by users side-loading an APK split generated from an App Bundle which is the wrong architecture for their device.

Are you able to reproduce this error on an app installed from the play store, rather than an APK downloaded from an unofficial source?

@mattdyoung
Copy link

Hi @khonkaengame @pqkluan @ben-j69 @benoitdion (and anyone else seeing this error).

We've been investigating further and there are a few scenarios where linkage errors can occur which would result in you seeing the error message ... couldn't find "libbugsnag-ndk.so":

These intermittent linkage errors can occur particularly on older versions of Android. Our suggested approach to avoid them would be to preload the SO file with ReLinker:

ReLinker.loadLibrary(this, "bugsnag-ndk");
Bugsnag.init(this);

If you're also using our ANR detection you may see a similar error message ... couldn't find "libbugsnag-plugin-android-anr.so" for which we'd recommend the same approach:

ReLinker.loadLibrary(this, "bugsnag-plugin-android-anr");
Bugsnag.init(this);

We did consider including and using ReLinker directly in bugsnag-android but decided against it as this would have had an impact on the size of the library, even for customers unaffected by this issue.

@khonkaengame
Copy link

@mattdyoung Thank you i will try.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants