question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SoLoader causes instrumented tests to crash

See original GitHub issue

Bug Report

SoLoader looks for libfbjni in the .test path during instrumented tests. I am not sure how it makes that decision, since package name still reports without .test. Since the tests use a debug variant, I don’t see a way to prevent Flipper loading during instrumented tests.

java.lang.UnsatisfiedLinkError: dlopen failed: library "/data/app/com.appscoop.takingroot.staging.test-1Dt01Y4N51I9qkS3sSAU3w==/base.apk!/lib/x86/libfbjni.so" not found
  at java.lang.Runtime.load0(Runtime.java:938)
  at java.lang.System.load(System.java:1631)
  at com.facebook.soloader.SoLoader$1.load(SoLoader.java:529)
  at com.facebook.soloader.DirectApkSoSource.loadLibrary(DirectApkSoSource.java:77)
  at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:1038)
  at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SoLoader.java:914)
  at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:826)
  at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:773)
  at com.facebook.soloader.NativeLoaderToSoLoaderDelegate.loadLibrary(NativeLoaderToSoLoaderDelegate.java:29)
  at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:51)
  at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:30)
  at com.facebook.jni.HybridData.<clinit>(HybridData.java:34)
  at com.facebook.flipper.android.FlipperThread.run(FlipperThread.java:25)
libfbjni.so not found on /vendor/lib
libfbjni.so not found on /system/lib
couldn't find DSO to load: libfbjni.so
 SoSource 0: com.facebook.soloader.DirectorySoSource[root = /data/app/com.appscoop.takingroot.staging-_zWOlH2oMX4dVzDGOq6zXw==/lib/x86 flags = 0]
 SoSource 1: com.facebook.soloader.DirectApkSoSource[root = /data/app/com.appscoop.takingroot.staging.test-1Dt01Y4N51I9qkS3sSAU3w==/base.apk!/lib/x86]
 SoSource 2: com.facebook.soloader.DirectorySoSource[root = /vendor/lib flags = 2]
 SoSource 3: com.facebook.soloader.DirectorySoSource[root = /system/lib flags = 2]
 Native lib dir: /data/app/com.appscoop.takingroot.staging-_zWOlH2oMX4dVzDGOq6zXw==/lib/x86
 result: 0
FATAL EXCEPTION: FlipperEventBaseThread
Process: com.appscoop.takingroot.staging, PID: 5862
java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libfbjni.so
    SoSource 0: com.facebook.soloader.DirectorySoSource[root = /data/app/com.appscoop.takingroot.staging-_zWOlH2oMX4dVzDGOq6zXw==/lib/x86 flags = 0]
    SoSource 1: com.facebook.soloader.DirectApkSoSource[root = /data/app/com.appscoop.takingroot.staging.test-1Dt01Y4N51I9qkS3sSAU3w==/base.apk!/lib/x86]
    SoSource 2: com.facebook.soloader.DirectorySoSource[root = /vendor/lib flags = 2]
    SoSource 3: com.facebook.soloader.DirectorySoSource[root = /system/lib flags = 2]
    Native lib dir: /data/app/com.appscoop.takingroot.staging-_zWOlH2oMX4dVzDGOq6zXw==/lib/x86
result: 0
    at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:1098)
    at com.facebook.soloader.SoLoader.loadLibraryBySoNameImpl(SoLoader.java:914)
    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:826)
    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:773)
    at com.facebook.soloader.NativeLoaderToSoLoaderDelegate.loadLibrary(NativeLoaderToSoLoaderDelegate.java:29)
    at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:51)
    at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:30)
    at com.facebook.jni.HybridData.<clinit>(HybridData.java:34)
    at com.facebook.flipper.android.FlipperThread.run(FlipperThread.java:25)
FATAL EXCEPTION: FlipperConnectionThread
Process: com.appscoop.takingroot.staging, PID: 5862
 java.lang.NoClassDefFoundError: <clinit> failed for class com.facebook.flipper.android.EventBase; see exception in other thread
    at com.facebook.flipper.android.FlipperThread.run(FlipperThread.java:25)

To Reproduce

Run an instrumented test

Environment

Android API 31 debugImplementation ‘com.facebook.flipper🐬0.137.0’ debugImplementation ‘com.facebook.soloader:soloader:0.10.3’ releaseImplementation ‘com.facebook.flipper:flipper-noop:0.137.0’

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
RowlandOticommented, Jul 18, 2022

Yes, I can see a commit that explains why this happens as well as the applied fix: https://github.com/facebook/SoLoader/commit/90084463c550b537501524f00153575d010b2f21

3reactions
ericschaalcommented, May 13, 2022

Hi,

I encountered the same issue while running Detox (instrumented tests) on a React Native 0.68 project with Hermes enabled. AndroidJUnitRunner would instantly crash at startup.

...
crashes with java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so

I was able to solve it by downgrading SoLoader to v0.9.0+ using resolutionStrategy.

Any idea why this is happening?

EDIT: I also tried various 0.10.x versions v0.10.1 is working v0.10.2 is crashing v0.10.3 is crashing

Looks like something broke in v0.10.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Soloader crash during instrumented test · Issue #3499 - GitHub
Bug Report For some reason SoLoader decides to look for libfbjni in the .test path during instrumented tests. I am not sure how...
Read more >
AndroidJUnitRunner - Android Developers
Crashes are isolated: Even if one test crashes, it takes down only its own instance of Instrumentation . This means that the other...
Read more >
Unable to configure zoom video sdk in react native project
callApplicationOnCreate(Instrumentation.java:1192) ... Usually this type of crash comes from missing dependencies in the project.
Read more >
Instrumentation tests crash in debug mode in Android Studio
After a long time, I accidentally found a solution. The tests run fine in debug mode if I disable instant run in Android...
Read more >
Use a pre-launch report to identify issues - Play Console Help
You can also provide custom tests or test account credentials for the crawler to use. After the crawl has finished, we compile your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found