react-native icon indicating copy to clipboard operation
react-native copied to clipboard

couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found

Open mhrpatel12 opened this issue 5 years ago • 140 comments

App crash on Android integration with existing apps.

Crash log.

E/SoLoader: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found
2019-07-07 18:59:27.223 10045-10073/com.mihir.reactApp E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: com.mihir.reactApp, PID: 10045
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found
        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.jscexecutor.JSCExecutor.<clinit>(JSCExecutor.java:19)
        at com.facebook.react.jscexecutor.JSCExecutorFactory.create(JSCExecutorFactory.java:29)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
        at java.lang.Thread.run(Thread.java:764)

React Native version:

System: OS: macOS 10.14.5 CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz Memory: 1.19 GB / 16.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 12.5.0 - /usr/local/bin/node Yarn: 1.16.0 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: Android SDK: API Levels: 21, 22, 23, 24, 25, 26, 27, 28, 29 Build Tools: 23.0.1, 25.0.2, 26.0.2, 27.0.3, 28.0.0, 28.0.3, 29.0.0, 29.0.0 System Images: android-22 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom IDEs: Android Studio: 3.4 AI-183.6156.11.34.5522156 Xcode: /undefined - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: ^0.60.0 => 0.60.0 npmGlobalPackages: react-native-cli: 2.0.1

Steps To Reproduce

  1. Create a new Android app which uses AndroidX.
  2. Add react-native to Android application as, implementation 'com.facebook.react:react-native:+'
  3. Run app on any android device/emulator.

Sample project on GitHub which reproduces crash.

mhrpatel12 avatar Jul 07 '19 14:07 mhrpatel12

@nicsachin For me, it's still not working. Did you tried running the sample project I've shared?

mhrpatel12 avatar Jul 08 '19 07:07 mhrpatel12

hi @mhrpatel12 ,

I'm having same issue. You can follow this link.

Add following code in build.gradle

def useIntlJsc = false

in dependency add in following

if (useIntlJsc) {
     implementation 'org.webkit:android-jsc-intl:+'
} else {
     implementation 'org.webkit:android-jsc:+'
}

crispywong avatar Jul 08 '19 11:07 crispywong

def useIntlJsc = false

Still no working,,,

ithustle avatar Jul 08 '19 11:07 ithustle

View the upgrade guide https://react-native-community.github.io/upgrade-helper/?from=0.59.10&to=0.60.0

You're likely missing the step android/build.gradle

allprojects {
    repositories {
        mavenLocal()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        google()
        jcenter()
    }
}

BrendonSled avatar Jul 08 '19 20:07 BrendonSled

I'm not migrating from .59 to .60. This issue happens even on a brand new android project which uses AndroidX. You can see for yourself on sample project I created.

mhrpatel12 avatar Jul 09 '19 04:07 mhrpatel12

Duplicate of #25415

Villar74 avatar Jul 09 '19 07:07 Villar74

@mhrpatel12 check out your file though. https://github.com/mhrpatel12/ReactApplication/blob/master/android/build.gradle

You're missing pieces

BrendonSled avatar Jul 09 '19 17:07 BrendonSled

@BrendonSled Were you able to run the app successfully after making those changes? For me, even after merging your changes it's not working.

mhrpatel12 avatar Jul 09 '19 18:07 mhrpatel12

@mhrpatel12 Have you made sure $rootDir/../node_modules/jsc-android/dist is a valid path in your project? If not, you need to do an npm install --save jsc-android

chrisspankroy avatar Jul 09 '19 19:07 chrisspankroy

@chrisspankroy yes, I have made sure that $rootDir/../node_modules/jsc-android/dist is a valid path in my project. I also did npm install --save jsc-android to double-check. Still, I'm getting the same issue. It'll be really helpful if you can share your working example repo.

mhrpatel12 avatar Jul 10 '19 04:07 mhrpatel12

Could you give it a try? I tried using your sample project. After done following changes, it works at my side

Add MainApplication.kt file and follow changes in diff.txt

package com.mihir.reactApp

import android.app.Application
import com.facebook.react.ReactApplication
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.shell.MainReactPackage
import com.facebook.soloader.SoLoader
import java.util.Arrays

class MainApplication : Application(), ReactApplication {
    private val mReactNativeHost = object : ReactNativeHost(this) {
        override fun getJSMainModuleName(): String {
            return "index"
        }

        override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
        override fun getPackages(): List<ReactPackage> =
                Arrays.asList(
                        MainReactPackage()
                )
    }

    override fun getReactNativeHost(): ReactNativeHost = mReactNativeHost
    override fun onCreate() {
        super.onCreate()
        SoLoader.init(this, false)
    }
}

diff.txt helloworld permission

crispywong avatar Jul 10 '19 05:07 crispywong

@crispywong thank you, it's working now. Still, I'm confused what's going on, why I'm able to run perfectly on version 0.59.10 without all these changes?

mhrpatel12 avatar Jul 10 '19 06:07 mhrpatel12

Add following code in app/build.gradle

def useIntlJsc = false

in dependency add in following

if (useIntlJsc) {
     implementation 'org.webkit:android-jsc-intl:+'
} else {
     implementation 'org.webkit:android-jsc:+'
}

For me worked that fix with

maven {
      // Android JSC is installed from npm
      url("$rootDir/../node_modules/jsc-android/dist")
    }

in build.gradle

Villar74 avatar Jul 10 '19 08:07 Villar74

Add following code in app/build.gradle

def useIntlJsc = false

in dependency add in following

if (useIntlJsc) {
     implementation 'org.webkit:android-jsc-intl:+'
} else {
     implementation 'org.webkit:android-jsc:+'
}

For me worked that fix with

maven {
      // Android JSC is installed from npm
      url("$rootDir/../node_modules/jsc-android/dist")
    }

in build.gradle

it is work for me, thanks

ahong222 avatar Jul 21 '19 08:07 ahong222

Fatal Exception: java.lang.UnsatisfiedLinkError
couldn't find DSO to load: libhermes.so
Fatal Exception: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libhermes.so
       at com.facebook.soloader.SoLoader.doLoadLibraryBySoName + 738(SoLoader.java:738)
       at com.facebook.soloader.SoLoader.loadLibraryBySoName + 591(SoLoader.java:591)
       at com.facebook.soloader.SoLoader.loadLibrary + 529(SoLoader.java:529)
       at com.facebook.soloader.SoLoader.loadLibrary + 484(SoLoader.java:484)
       at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit> + 20(HermesExecutor.java:20)
       at com.facebook.hermes.reactexecutor.HermesExecutorFactory.create + 27(HermesExecutorFactory.java:27)
       at com.facebook.react.ReactInstanceManager$5.run + 949(ReactInstanceManager.java:949)
       at java.lang.Thread.run + 818(Thread.java:818)
"react": "16.8.6",
"react-native": "0.60.4",

rochapablo avatar Jul 25 '19 10:07 rochapablo

Did you add below in android/app/build.gradle?

def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
if (enableHermes) {
      def hermesPath = "../../node_modules/hermesvm/android/";
      debugImplementation files(hermesPath + "hermes-debug.aar")
      releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
      implementation jscFlavor
    }

crispywong avatar Jul 25 '19 12:07 crispywong

在app / build.gradle中添加以下代码

def useIntlJsc = false

在依赖中添加以下内容

if (useIntlJsc) {
     implementation 'org.webkit:android-jsc-intl:+'
} else {
     implementation 'org.webkit:android-jsc:+'
}

对我来说,修复过

maven {
      // Android JSC is installed from npm
      url("$rootDir/../node_modules/jsc-android/dist")
    }

在build.gradle中

这对我有用,谢谢 this fixed my problem.

tianzige666 avatar Aug 15 '19 17:08 tianzige666

Add following code in app/build.gradle

def useIntlJsc = false

in dependency add in following

if (useIntlJsc) {
     implementation 'org.webkit:android-jsc-intl:+'
} else {
     implementation 'org.webkit:android-jsc:+'
}

For me worked that fix with

maven {
      // Android JSC is installed from npm
      url("$rootDir/../node_modules/jsc-android/dist")
    }

in build.gradle

@Villar74 thanks its work for me.

abhijeetkharat avatar Aug 30 '19 11:08 abhijeetkharat

I fixed this problem in this link https://stackoverflow.com/questions/57113794/getting-java-lang-unsatisfiedlinkerror-couldnt-find-dso-to-load-libhermes-so/57744477#57744477

saeedhassankhan avatar Sep 01 '19 08:09 saeedhassankhan

if you have this error it means that you have a jsc aar missing, you can find it in node_modules\jsc-android\dist

Make sure it is included in your dependencies

yurykorzun avatar Sep 09 '19 18:09 yurykorzun

I think if peoples sure that config for android correct. So, check your android/app/build.gradle

If have two lines after:

    pickFirst '**/x86_64/libjsc.so'
    pickFirst '**/arm64-v8a/libjsc.so'

~Remove it resolved my problem. So hope it will help all you guys~

Replace your packagingOptions with values from default RN config

packagingOptions {
            pickFirst '**/armeabi-v7a/libc++_shared.so'
            pickFirst '**/x86/libc++_shared.so'
            pickFirst '**/arm64-v8a/libc++_shared.so'
            pickFirst '**/x86_64/libc++_shared.so'
            pickFirst '**/x86/libjsc.so'
            pickFirst '**/armeabi-v7a/libjsc.so'
}

william-normann avatar Oct 30 '19 07:10 william-normann

@yurykorzun

if you have this error it means that you have a jsc aar missing, you can find it in node_modules\jsc-android\dist

Make sure it is included in your dependencies

How?

roots-ai avatar Oct 30 '19 16:10 roots-ai

check your android/app/build.gradle

android {
   ...
   packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
    }
}

zhuweideng avatar Oct 31 '19 07:10 zhuweideng

@zhuweideng Thanks

roots-ai avatar Nov 05 '19 13:11 roots-ai

@zhuweideng, packagingOptions section appeared in 0.62.0-rc.0, but it differs from your version a little bit: Снимок экрана 2019-12-30 в 15 43 17 Снимок экрана 2019-12-30 в 15 43 45

6 libraries in your version vs 4 in default config version, are you sure that they are all required?

check your android/app/build.gradle

android {
   ...
   packagingOptions {
        pickFirst '**/armeabi-v7a/libc++_shared.so'
        pickFirst '**/x86/libc++_shared.so'
        pickFirst '**/arm64-v8a/libc++_shared.so'
        pickFirst '**/x86_64/libc++_shared.so'
        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
    }
}

artshevtsov avatar Dec 30 '19 12:12 artshevtsov

hi @mhrpatel12 ,

I'm having same issue. You can follow this link.

Add following code in build.gradle

def useIntlJsc = false

in dependency add in following

if (useIntlJsc) {
     implementation 'org.webkit:android-jsc-intl:+'
} else {
     implementation 'org.webkit:android-jsc:+'
}

@mhrpatel12 check out your file though. https://github.com/mhrpatel12/ReactApplication/blob/master/android/build.gradle

You're missing pieces

Wha is missing there?

I have added below code also. But still it is not working

    maven {
        // Android JSC is installed from npm
        url("$rootDir/../node_modules/jsc-android/dist")
    }

itvignes09 avatar Feb 04 '20 09:02 itvignes09

hi @mhrpatel12 ,

I'm having same issue. You can follow this link.

Add following code in build.gradle

def useIntlJsc = false

in dependency add in following

if (useIntlJsc) {
     implementation 'org.webkit:android-jsc-intl:+'
} else {
     implementation 'org.webkit:android-jsc:+'
}

Your link is redirecting invalid page regarding this conversation. Also your solution is not working

itvignes09 avatar Feb 04 '20 09:02 itvignes09

E/SoLoader: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: APK was built for a different platform

Tried every single solution in the thread and it doesn't work. I vent from RN 0.59 to 0.62.. Same error. Every minor update is a breaking update. It really starts to bother us.

raphaelgodro avatar Apr 19 '20 18:04 raphaelgodro

E/SoLoader: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: APK was built for a different platform

Tried every single solution in the thread and it doesn't work. I vent from RN 0.59 to 0.62..

Same error. Every minor update is a breaking update. It really starts to bother us.

I am able to fix it by adding the following dependencies to app/build.gradle

debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
  exclude group:'com.facebook.fbjni'
}

debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
    exclude group:'com.facebook.flipper'
}

and adding the version in android/gradle.properties FLIPPER_VERSION=0.33.1

yeong0809 avatar Apr 28 '20 13:04 yeong0809

I've downgrade from 0.62.2 to 0.61.5 and now it's work. It's weird because on physical device the app work fine but on emulator the app crash

2020-04-28 18:55:02.126 7662-7699/? E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
    Process: com.cprassistant, PID: 7662
    java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libglog_init.so caused by: couldn't find DSO to load: libglog.so caused by: APK was built for a different platform
        at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:789)
        at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:639)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:577)
        at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:525)
        at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:34)
        at com.facebook.react.bridge.Inspector.<clinit>(Inspector.java:21)
        at com.facebook.react.bridge.Inspector.getPages(Inspector.java:28)
        at com.facebook.react.devsupport.InspectorPackagerConnection.getPages(InspectorPackagerConnection.java:151)
        at com.facebook.react.devsupport.InspectorPackagerConnection.handleProxyMessage(InspectorPackagerConnection.java:66)
        at com.facebook.react.devsupport.InspectorPackagerConnection$Connection.onMessage(InspectorPackagerConnection.java:221)
        at okhttp3.internal.ws.RealWebSocket.onReadMessage(RealWebSocket.java:323)
        at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.java:219)
        at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.java:105)
        at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.java:274)
        at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:214)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:206)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)

UpperM avatar Apr 28 '20 17:04 UpperM