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

[ANDROID] SoLoader error using App Bundle #23764

Closed
vanydeasy opened this issue Mar 5, 2019 · 106 comments
Closed

[ANDROID] SoLoader error using App Bundle #23764

vanydeasy opened this issue Mar 5, 2019 · 106 comments
Labels
Bug Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.

Comments

@vanydeasy
Copy link

vanydeasy commented Mar 5, 2019

🐛 Bug Report

Please help!
There are some crashes happening in android using app bundle but I am not sure how to reproduce it. It happens on our app with daily crash of 200 users.

Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so
       at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
       at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
       at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
       at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
       at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:30)
       at com.facebook.react.bridge.NativeMap.(NativeMap.java:19)
       at com.facebook.react.jscexecutor.JSCExecutorFactory.create(JSCExecutorFactory.java:25)
       at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:944)
       at java.lang.Thread.run(Thread.java:764)

The errors have multiple variations that occur on various android versions.

Fatal Exception: java.lang.UnsatisfiedLinkError
couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libfb.so caused by: couldn't find DSO to load: libgnustl_shared.so caused by: dlopen failed: "/data/data/com.traveloka.android/lib-0/libgnustl_shared.so" is 64-bit instead of 32-bit
Fatal Exception: java.lang.UnsatisfiedLinkError
couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libfb.so caused by: Dynamic section string-table not found
Fatal Exception: java.lang.UnsatisfiedLinkError
couldn't find DSO to load: libreactnativejni.so

To Reproduce

We have tried to reproduce it with many devices but we can only reproduce it in one condition.

  1. Install the release app
  2. Upgrade OS from 32bit to 64bit
  3. Open the app

If we reinstall the app afterwards, it works fine.
Although, we are still unsure whether it is the only error case.

Expected Behavior

The app does not crash on any device.

Code Example

android {
    ...
    defaultConfig {
       ...
        ndk {	
            abiFilters "armeabi-v7a", "x86", "arm64-v8a"
        }
    }
}

Environment

React Native Environment Info:
    System:
      OS: macOS 10.14
      CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 4.93 GB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.10.0 - ~/.nvm/versions/node/v8.10.0/bin/node
      Yarn: 1.13.0 - /usr/local/bin/yarn
      npm: 6.8.0 - ~/.nvm/versions/node/v8.10.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        Build Tools: 23.0.1, 24.0.0, 24.0.3, 26.0.2, 26.0.3, 27.0.0, 27.0.3, 28.0.0, 28.0.2, 28.0.3
        API Levels: 23, 24, 25, 26, 27, 28
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5264788
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3 
      react-native: 0.58.4 => 0.58.4 
@react-native-bot react-native-bot added Platform: Android Android applications. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used. labels Mar 5, 2019
@radeno
Copy link
Contributor

radeno commented Mar 5, 2019

Can you sync config files with RN0.58 Android template https://github.com/facebook/react-native/tree/0.58-stable/local-cli/templates/HelloWorld/android and try again?

EDIT:

And update to latest RN 0.58.6 please.

@RoJoHub
Copy link
Contributor

RoJoHub commented Mar 6, 2019

image
Some Device haven't the lib of armeabi .

How to get lib?

  1. rename your apk to xxxx.rar.
  2. Go into xxxx/lib/,now you can see armeabi directory.
  3. Get libreactnativejni.so

@vanydeasy
Copy link
Author

@radeno I have synced all config files to 0.58 except BUCK. Although it's hard to copy it as it is since our app is brownfield. Pretty sure there is no native changes from 0.58.4 to 0.58.6.

@RoJoHub Do you mean that the libreactnativejni.so is not included on some ABIs? since I'm sure it's all there.
image

@RoJoHub
Copy link
Contributor

RoJoHub commented Mar 11, 2019

Also you should create directory of armabi.
Copy files from armeabi-v7a to armabi.

For your question, please confirm what architecture your device is.
If the device is an armabi architecture, then you can solve your problem.

@radeno
Copy link
Contributor

radeno commented Mar 11, 2019

@vanydeasy i understand your concerns. You can diff files with for example VSCode (Compare file). Or if you upgraded from lower version check it with https://github.com/react-native-community/rn-diff-purge. I just want to as much as possible to have identical configs, to eliminate diffs. It sometimes really helps to find problematic issue.

But i think i have found your issue.
As you can see this commit 07d1075 in description is that SoLoader was updated to newer version for Supporting App Bundle. It is available in 0.59-RC version.
Official production ready should be released in monday/tuesday.

@vanydeasy
Copy link
Author

@RoJoHub from this doc, i got that armabi is deprecated meanwhile the crashes happen on several other architectures as well.

@radeno yes we use https://github.com/react-native-community/rn-diff-purge as well to upgrade our app. Do you want me to list down every possible difference based on it?
And also, from what I understand, SoLoader 0.6.0 has been included on 0.58.4.

@radeno
Copy link
Contributor

radeno commented Mar 12, 2019

@vanydeasy you are right. SoLoader was backported. My mistake.
Then it is weird. Is it same results for clean RN 0.58 init?
We don't use 64bit for Android yet because some other packages are not compatible yet.

@RoJoHub
Copy link
Contributor

RoJoHub commented Mar 14, 2019

I think we should browse this page.
https://developer.android.com/ndk/guides/abis?hl=en

Specially.


Automatic extraction of native code at install time

When installing an application, the package manager service scans the APK, and looks for any shared libraries of the form:

lib/<primary-abi>/lib<name>.so

If none is found, and you have defined a secondary ABI, the service scans for shared libraries of the form:

lib/<secondary-abi>/lib<name>.so

When it finds the libraries that it's looking for, the package manager copies them to /lib/lib.so, under the application's data directory (data/data/<package_name>/lib/).

If there is no shared-object file at all, the application builds and installs, but crashes at runtime.

@RoJoHub
Copy link
Contributor

RoJoHub commented Mar 14, 2019


To Reproduce
We have tried to reproduce it with many devices but we can only reproduce it in one condition.

Install the release app
Upgrade OS from 32bit to 64bit
Open the app

If you update android,maybe system will not search again.Unless reinstall

@miguelslemos
Copy link

miguelslemos commented Mar 15, 2019

I had the same issue with AGP 3.3.2. For now, we are downgrading to AGP 3.2.0 until bump RN to 0.59

facebook/SoLoader#26
#23239

facebook/SoLoader#26 (comment)

@dulmandakh
Copy link
Contributor

@vanydeasy could you please check CPU architecture of devices crashing. It seems that x86_64 is missing from abiFilters, and that might causing issues on x86_64 architecture.

@dulmandakh
Copy link
Contributor

also could you please check if it still persists on 0.59.x?

@grabbou
Copy link
Contributor

grabbou commented Mar 19, 2019

Is this something that could be fixed by: 4b996da? Would be good to know whether this issue persists on 0.59.1 where this commit is included.

@vanydeasy
Copy link
Author

vanydeasy commented Mar 22, 2019

@RoJoHub You are probably right but doesn't that mean that the fault is on android side then?

@miguelslemos SoLoader v0.6.0 was backported to RN v0.58.4 which we are using. The problem still persists.

@dulmandakh x86_64 just got included on 0.59, right? So I don't think that's the case. It even crashes on Samsung s10 which uses ARM architecture. But I'm going to update you after I upgrade to 0.59.

@grabbou Don't think that's the case since x86_64 is not even included on RN 0.58.

@OllyDixon Oh really? I'm using gradle plugin 3.3.2 now. What version of RN are you using btw?

@RoJoHub
Copy link
Contributor

RoJoHub commented Mar 23, 2019

Is this something that could be fixed by: 4b996da? Would be good to know whether this issue persists on 0.59.1 where this commit is included.

It's just a temple.

@RoJoHub
Copy link
Contributor

RoJoHub commented Mar 23, 2019

@RoJoHub你可能是对的,但这是不是意味着故障在android方面呢?

@miguelslemos SoLoader v0.6.0被反向移植到我们正在使用的RN v0.58.4。问题仍然存在。

@dulmandakh x86_64刚被纳入0.59,对吗?所以我认为不是这样的。它甚至在使用ARM架构的三星s10上崩溃。但升级到0.59后我会更新你。

@grabbou不要认为是这种情况,因为RN 0.58甚至没有包含x86_64。

@OllyDixon哦真的吗?我现在正在使用gradle插件3.3.2。您使用什么版本的RN btw?

In you gradle

android {
    ...
    defaultConfig {
       ...
        ndk {	
            abiFilters "armeabi-v7a", "x86", "arm64-v8a"
        }
    }
}

image

Different Android handsets use different CPUs, which in turn support different instruction sets. Each combination of CPU and instruction sets has its own Application Binary Interface, or ABI. The ABI defines, with great precision, how an application's machine code is supposed to interact with the system at runtime. You must specify an ABI for each CPU architecture you want your app to work with.


Some device will run on armeabi architecture.

image


I have already said it before. Why don't you try it.
I am very confused.

#23764 (comment)

@ollyde
Copy link

ollyde commented Mar 23, 2019

@RoJoHub many of us use deployment pipelines and don't have access to directories. Also this is a hack not a fix and for any other team members on the project they need to be aware of this on each build.

@RoJoHub
Copy link
Contributor

RoJoHub commented Mar 23, 2019

@RoJoHub many of us use deployment pipelines and don't have access to directories. Also this is a hack not a fix and for any other team members on the project they aware of this on each build.


In a reply, I chose the wrong people.Sorry. @OllyDixon
Now re-edited.

#23764 (comment)


I did not say to add lib at build time.
If you look at my statement carefully.

#23764 (comment)


This image is just to express the results after the file is added.

image


I correct my answer.
We should create armeabi at projectpath/android/app/src/main/jniLibs.
And copy files from apk/lib/armeabi-v7a to projectpath/android/app/src/main/jniLibs/armeabi.

@RoJoHub
Copy link
Contributor

RoJoHub commented Mar 23, 2019

How anyone else having issues downgrading to gradle plugin 3.2.+ solved it for me.

In the top level build.gradle file change to:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.+'
}

I'm using React 57.1 I cannot get 58 and 59 to work, have many libraries in a large project.

In addition, according to my experience, your solution is not related to her problem.

I think this is not a react-native issue, and this issue should be closed.

@vanydeasy
Copy link
Author

vanydeasy commented Mar 25, 2019

@RoJoHub I'm confused. We do not even include armeabi on ndkFilters. But the lack of several so files on armeabi architecture can still be the source of the problem?

@RoJoHub
Copy link
Contributor

RoJoHub commented Mar 25, 2019

@RoJoHub I'm confused. We do not even include armeabi on ndkFilters. But the lack of several so files on armeabi architecture can still be the source of the problem?

For example,my device is ARMv7 Processor rev 1 (v7l)

Use adb

image

Use Java Code

/**
     * The name of the instruction set (CPU type + ABI convention) of native code.
     * @deprecated Use {@link #SUPPORTED_ABIS} instead.
     */
String cpuInfo = android.os.Build.CPU_ABI;

image


  1. First, determine what CPU architecture is on the device where the problem occurred.
  2. If the architecture of the device is armeabi, then your problem is caused by this cause.

@slestang
Copy link

slestang commented Apr 4, 2019

I had the same issue while using Android bundle with RN 0.59.0. Some devices work and other don't and I didn't find the key differences.

It seems I have fixed it by removing the override of the versionCode for each variants in android/app/build.gradle:

-    // applicationVariants are e.g. debug, release
-    applicationVariants.all { variant ->
-        variant.outputs.each { output ->
-            // For each separate APK per architecture, set a unique version code as described here:
-            // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
-            def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4]
-            def abi = output.getFilter(OutputFile.ABI)
-            if (abi != null) {  // null for the universal-debug, universal-release variants
-                output.versionCodeOverride =
-                        versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
-            }
-        }
-    }

The Android doc says it is no longer require when using bundle (I don't have enough knowledge of Android's internal to understand why it was require in the first place).

Note: I don't have any abiFilters.

I am not 100% sure of the fix yet as I only tested locally on 1 device with an APK extracted from my bundle with bundletool. I will confirm the fix latter after deploying the APKs on enough devices through Google Play console.

@vanydeasy
Copy link
Author

@RoJoHub the devices that crash have 2 or 3 supported ABIs; arm64-v8a, armeabi-v7a, armeabi. So, I don't think that's the case? Except the devices only support armeabi, right?

@slestang we have removed the following code but still get the same error. Weird that re-installing fix the issues for us.

@slestang
Copy link

slestang commented Apr 8, 2019

@vanydeasy after more than one day of debugging I still haven't figure it out in which conditions the bug is triggered (my "fix" above is definitively not working) :-[

In my case it seems very random; in most cases it crash but sometimes after a re-install, the App works fine until a re-start and then it keep crashing. I will try to find more time later this week to investigate the differences between the working and non-working APKs.

@tapz
Copy link

tapz commented Apr 14, 2020

This fixed the issue for me in RN 0.62.2:

rm -rf $HOME/.gradle/caches/

@soroushm
Copy link

This fixed the issue for me in RN 0.62.2:

rm -rf $HOME/.gradle/caches/

I have same issue it coming after clear caches and reinstall it happend
v0.62.2

@soroushm
Copy link

Dublicate issue
#28163

this command work for me
cd android/
Run
./gradlew clean

That should probably fix this.

@Michaelvons
Copy link

This fixed the issue for me in RN 0.62.2:

rm -rf $HOME/.gradle/caches/

@tapz is correct. Just do what he suggested.
Works like charm!!

@vanydeasy
Copy link
Author

In my case, the error does not appear on 0.61.5 anymore. Should I close this?

@xgAnd
Copy link

xgAnd commented Jun 15, 2020

In my case, the error does not appear on 0.61.5 anymore. Should I close this? my RN version is "react-native": "^0.61.5", still has the error.
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libflipper.so caused by: dlopen failed: library "libfbjni.so" not found result: 0
at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:825)
at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:673)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:611)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:559)
at com.facebook.flipper.android.EventBase.(EventBase.java:19)
at com.facebook.flipper.android.FlipperThread.run(FlipperThread.java:25)

@nickarora
Copy link

nickarora commented Jun 18, 2020

This is not fixed for us. I would not close this issue.

v 0.62.2
rm -rf $HOME/.gradle/caches/
completely clean android install.

Fails on an emulator installed with API 30 and API 28 with several errors all following the same format.

Strangely, it runs on API 29. This might be a clue. It seems the targeted emulator plays a role.

java.lang.UnsatisfiedLinkError: dlopen failed: "/data/user/0/<BUNDLE-ID>/lib-main/libc++_shared.so" is for EM_ARM (40) instead of EM_386 (3)

The issue referenced on the SoLoader repo perfectly describes the problem -- but., since SoLoader, ships with react-native this seems like a ReactNative problem too.

@bill2004158
Copy link
Contributor

I have got same issue:
Fails on an emulator installed with API 30, but runs on API 29

@ryd0rz
Copy link

ryd0rz commented Jul 11, 2020

I also have this issue, are there any temporary workarounds? I don't mind editing some node modules manually :)

@danielbattat
Copy link

I am getting:
unknown:NativeModuleInitError: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativeblob.so caused by: Error: Cannot load /data/app/com.***********-1/lib/arm/libreactnativeblob.so result: 0

with
"react": "16.13.1",
"react-native": "0.63.2",

android {
...
   buildtypes {
   ...
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }

I've tried all the suggestions in this thread and nothing worked. Any suggestions?

@fabriciodanioj
Copy link

cd android && ./gradlew clean worked for me

@jimmyceroneii
Copy link

@fabriciodanioj do you know why that worked? I'm having the same issue with the following specs:

  • Detox: ^17.0.0
  • React Native: 0.62.2
  • Node: 12.18.0
  • Jest: ^24.9.0
  • Jest Circus: ^26.1.0
  • Typescript: ^3.8.3
  • Yarn: 1.22.4

@fabriciodanioj
Copy link

@fabriciodanioj do you know why that worked? I'm having the same issue with the following specs:

* Detox: ^17.0.0

* React Native: 0.62.2

* Node: 12.18.0

* Jest: ^24.9.0

* Jest Circus: ^26.1.0

* Typescript: ^3.8.3

* Yarn: 1.22.4

@jimmyceroneii sorry. I dont know.

@jimmyceroneii
Copy link

jimmyceroneii commented Sep 9, 2020

@fabriciodanioj I just tried it out and it kind of worked for me. The crashing is gone (yay!) but now it is refusing to connect with my development server. I don't know if the two are connected, but I'm guessing no. Anyway, thanks for your help!

@shukerullah
Copy link

I have got same issue:
Fails on an emulator installed with API 30, but runs on API 29

Same, it's crashing on emulator installed with API 30. How did you fix this issue?

@EnettyTech
Copy link

EnettyTech commented Dec 15, 2020

Issue persists still for today.
Screen Shot 2020-12-15 at 09 40 46
-React Native: 0.61.4
-React: 16.9.0

@shukerullah
Copy link

Crashing SoLoader.java line 896 com.facebook.soloader.SoLoader.doLoadLibraryBySoName after updating SoLoader to 0.9.0 and its crashing only on Android 9 and lower.

  • React: 16.11.0
  • React Native: 0.62.2
  • SoLoader: 'com.facebook.soloader:soloader:0.9.0+'

report

@grantgeorge
Copy link

grantgeorge commented Dec 16, 2020

This seems like the most promising solution to the problem:

facebook/SoLoader#59 (comment)

I was running into the same issue but wasn't able to simply upgrade react-native because of some other dependencies.

The fix for this issue is part of SoLoader 0.8.1, you only need to force this dependency to a version higher than 0.8.0.

Root level build.gradle

allprojects {
    repositories {
        google()
        center()
		...

        // force dependency versions on all subprojects
        configurations.all {
            resolutionStrategy {

                // use 0.9.0 to fix crash on Android 11
                force "com.facebook.soloader:soloader:0.9.0"
			}
		}
	}
}

@arjuntraj
Copy link

I am getting:
unknown:NativeModuleInitError: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativeblob.so caused by: Error: Cannot load /data/app/com.***********-1/lib/arm/libreactnativeblob.so result: 0

with
"react": "16.13.1",
"react-native": "0.63.2",

android {
...
   buildtypes {
   ...
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }

I've tried all the suggestions in this thread and nothing worked. Any suggestions?

Any solution? still facing the same issue.

@eshunnar
Copy link

Crashing SoLoader.java line 896 com.facebook.soloader.SoLoader.doLoadLibraryBySoName after updating SoLoader to 0.9.0 and its crashing only on Android 9 and lower.

  • React: 16.11.0
  • React Native: 0.62.2
  • SoLoader: 'com.facebook.soloader:soloader:0.9.0+'
report

Same issue here.

@minhchienwikipedia
Copy link

Crashing SoLoader.java line 896 com.facebook.soloader.SoLoader.doLoadLibraryBySoName after updating SoLoader to 0.9.0 and its crashing only on Android 9 and lower.

  • React: 16.11.0
  • React Native: 0.62.2
  • SoLoader: 'com.facebook.soloader:soloader:0.9.0+'
report

Same issue here.

Same here, any update?

@soroushm
Copy link

facebook/SoLoader#59 (comment)

try this one
facebook/SoLoader#59 (comment)

@github-actions
Copy link

github-actions bot commented Mar 4, 2023

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 4, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

@facebook facebook locked as resolved and limited conversation to collaborators Mar 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: Android Android applications. Stale There has been a lack of activity on this issue and it may be closed soon. Tech: Bundler 📦 This issue is related to the bundler (Metro, Haul, etc) used.
Projects
None yet
Development

No branches or pull requests