khateeb
khateeb

Reputation: 5469

Getting library "libjsc.so" not found after upgrading React Native to 0.60-RC2

I have updated React Native to 0.60-RC2, migrated to AndroidX using the Android Studio refractor and used the jetifier mentioned here: https://github.com/react-native-community/discussions-and-proposals/issues/129

After doing this, I get the error library "libjsc.so" not found when running react-native run-android. i get the same error when running a release APK.

The stacktrace is:

06-24 15:55:01.823  8579  8656 E SoLoader: Error when loading lib: dlopen failed: library "libjsc.so" not found lib hash: 83f1717c1dc187d9f252a9f1fc66d430 search path is /data/app/com.jtv.testapp-4hvCKbqEmbyyOPykuQhm4Q==/lib/arm
06-24 15:55:01.823  8579  8656 E SoLoader: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found
06-24 15:55:01.825  8579  8656 E AndroidRuntime: FATAL EXCEPTION: create_react_context
06-24 15:55:01.825  8579  8656 E AndroidRuntime: Process: com.jtv.testapp, PID: 8579
06-24 15:55:01.825  8579  8656 E AndroidRuntime: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found
06-24 15:55:01.825  8579  8656 E AndroidRuntime:    at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:738)
06-24 15:55:01.825  8579  8656 E AndroidRuntime:    at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:591)
06-24 15:55:01.825  8579  8656 E AndroidRuntime:    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:529)
06-24 15:55:01.825  8579  8656 E AndroidRuntime:    at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:484)
06-24 15:55:01.825  8579  8656 E AndroidRuntime:    at com.facebook.react.jscexecutor.JSCExecutor.<clinit>(JSCExecutor.java:19)
06-24 15:55:01.825  8579  8656 E AndroidRuntime:    at com.facebook.react.jscexecutor.JSCExecutorFactory.create(JSCExecutorFactory.java:29)
06-24 15:55:01.825  8579  8656 E AndroidRuntime:    at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:949)
06-24 15:55:01.825  8579  8656 E AndroidRuntime:    at java.lang.Thread.run(Thread.java:764)

My package.json is:

{
  "name": "TestApp",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.2.0",
    "@react-native-community/blur": "^3.3.1",
    "@react-native-community/netinfo": "^1.2.3",
    "@react-native-community/slider": "^1.0.4",
    "axios": "^0.18.0",
    "jetifier": "^1.4.0",
    "native-base": "^2.10.0",
    "prop-types": "^15.6.2",
    "qs": "^6.6.0",
    "react": "^16.8.6",
    "react-native": "^0.60.0-rc.2",
    "react-native-appsee": "^2.6.21",
    "react-native-device-info": "^0.24.3",
    "react-native-dialog": "^5.5.0",
    "react-native-draggable-flatlist": "^1.1.7",
    "react-native-elements": "^0.19.1",
    "react-native-email": "^1.0.2",
    "react-native-fast-image": "^5.1.2",
    "react-native-gesture-handler": "^1.0.12",
    "react-native-iap": "^2.4.0",
    "react-native-image-picker": "^0.28.0",
    "react-native-iphone-x-helper": "^1.2.0",
    "react-native-keyboard-aware-scroll-view": "^0.8.0",
    "react-native-kochava-tracker": "^1.1.0",
    "react-native-linear-gradient": "^2.5.3",
    "react-native-material-dropdown": "^0.11.1",
    "react-native-modal": "^9.0.0",
    "react-native-orientation": "^3.1.3",
    "react-native-scrollable-tab-view": "^0.10.0",
    "react-native-snap-carousel": "^3.7.5",
    "react-native-super-grid": "^2.4.4",
    "react-native-tab-view": "^1.3.1",
    "react-native-underline-tabbar": "^1.3.6",
    "react-native-vector-icons": "^6.1.0",
    "react-native-video": "^4.3.1",
    "react-native-webview": "^5.12.0",
    "react-navigation": "^3.0.9",
    "react-navigation-backhandler": "^1.2.0",
    "react-redux": "^6.0.1",
    "redux": "^4.0.1",
    "redux-logger": "^3.0.6",
    "redux-thunk": "^2.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.4.0",
    "@babel/runtime": "^7.4.2",
    "@react-native-community/eslint-config": "^0.0.3",
    "babel-jest": "^24.5.0",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "eslint": "^5.15.3",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-plugin-import": "^2.16.0",
    "eslint-plugin-jsx-a11y": "^6.2.1",
    "eslint-plugin-react": "^7.12.4",
    "eslint-plugin-react-hooks": "^1.5.1",
    "jest": "^24.5.0",
    "metro-react-native-babel-preset": "^0.53.1",
    "react-devtools-core": "^3.6.0",
    "react-test-renderer": "^16.8.6",
    "remote-redux-devtools": "^0.5.16"
  },
  "jest": {
    "preset": "react-native"
  }
}

My build.gradle is:

apply plugin: "com.android.application"

import com.android.build.OutputFile

project.ext.react = [
        entryFile: "index.js"
]

apply from: "../../node_modules/react-native/react.gradle"

def enableSeparateBuildPerCPUArchitecture = false

def enableProguardInReleaseBuilds = false

project.ext.vectoricons = [
    iconFontNames: [ 'MaterialIcons.ttf', 'FontAwesome.ttf', 'MaterialCommunityIcons.ttf' ]
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.jtv.testapp"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 29
        versionName "0.0.1"
        multiDexEnabled true
        renderscriptTargetApi 29
        renderscriptSupportModeEnabled true
        ndk {
            abiFilters "arm64-v8a", "x86_64","armeabi-v7a", "x86"
        }
        packagingOptions {
            pickFirst 'lib/x86_64/libjsc.so'
            pickFirst 'lib/arm64-v8a/libjsc.so'
            exclude "lib/arm64-v8a/libimagepipeline.so"
            exclude "lib/arm64-v8a/librealm-jni.so"
        }
    }
    signingConfigs {
        release {
            if (project.hasProperty('RELEASE_STORE_FILE')) {
                storeFile file(RELEASE_STORE_FILE)
                storePassword RELEASE_STORE_PASSWORD
                keyAlias RELEASE_KEY_ALIAS
                keyPassword RELEASE_KEY_PASSWORD
            }
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
        }
    }
    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            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
            }
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation project(':react-native-webview')
    implementation project(':react-native-jtv-comic-reader')
    //implementation project(':@react-native-community_slider')
    implementation project(':@react-native-community_blur')
    implementation project(':@react-native-community_async-storage')
    implementation project(':@react-native-community_netinfo')
    implementation project(':react-native-appsee')
//    implementation project(':react-native-tune-sdk')
    implementation project(':react-native-iap')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-video')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-orientation')
    implementation project(':react-native-linear-gradient')
    implementation project(':react-native-kochava-tracker')
//    implementation project(':react-native-flurry-analytics')
    implementation project(':react-native-device-info')
//    implementation project(':react-native-fbsdk')
    implementation project(':react-native-fast-image')
    implementation project(':react-native-image-picker')
    implementation fileTree(dir: "libs", include: ["*.jar"])

    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.facebook.fresco:fresco:1.13.0'
    implementation 'com.facebook.fresco:animated-gif:1.13.0'
    implementation 'androidx.mediarouter:mediarouter:1.0.0'

    implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.11.2'
    implementation 'com.google.android.gms:play-services-ads:18.0.0'
    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
    implementation 'androidx.multidex:multidex:2.0.1'

    implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'
    implementation 'com.android.installreferrer:installreferrer:1.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.36.1'
    implementation 'com.swrve.sdk.android:swrve-firebase:6.0.1'
    implementation 'com.google.firebase:firebase-core:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:19.0.0'

    implementation 'androidx.mediarouter:mediarouter:1.0.0'
    implementation 'com.google.android.gms:play-services-cast:17.0.0'
    implementation 'com.googlecode.android-query:android-query:0.25.9'
    implementation 'com.google.android.gms:play-services-cast-framework:17.0.0'
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
    from configurations.compile
    into 'libs'
}
apply plugin: 'com.google.gms.google-services'

What is the libjsc.so file and how do I solve this error?

Upvotes: 28

Views: 27224

Answers (6)

HarshitMadhav
HarshitMadhav

Reputation: 5079

Okay ! In the recent versions of react native till today this issue is occurring and is being reported in the crashlytics that you integrate within the app or you can see it in the logs.

This issue only comes when you have Hermes engine enabled.

Here is my fix for this I was facing this issue, in my case Hermes was needed so, I managed to fix this "libjsc.so" not found by installing the jsc-android package from npm. Here is the link.

Please NOTE : Refer to the docs of this package for proper installation as per your react native version

clean gradle and re run the entire app this issue will be gone.

Upvotes: 1

Francois Nadeau
Francois Nadeau

Reputation: 7463

I had this issue too. I needed to update the jscFlavor variable inside the build.gradle file from this:

def jscFlavor = 'org.webkit:android-jsc:+'

To this:

def jscFlavor = 'org.webkit:android-jsc-intl:+'

Cheers.

Upvotes: 7

Jose Kj
Jose Kj

Reputation: 2962

In my case, This error was related with react-native-screen and adding following following two lines to dependencies section in android/app/build.gradle fixed the issue for me

implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha02'

Source:Check out this Github answer

Upvotes: 0

anthonyhumphreys
anthonyhumphreys

Reputation: 1081

I encountered a slight variation of this bug, where I had added a third buildType to my gradle config, 'releaseStaging'

The fix in this instance was to add the following line to dependencies in app/build.gradle

releaseStagingImplementation files(hermesPath + "hermes-release.aar")

Upvotes: 6

Tiago Gouv&#234;a
Tiago Gouv&#234;a

Reputation: 16780

What solved for me was change build.gradle updating packagingOptions to:

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

Upvotes: 6

Bhaskar Gyan Vardhan
Bhaskar Gyan Vardhan

Reputation: 9227

Add below in your app/build.gradle

// On top of the file

def useIntlJsc = false

//inside dependencies

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

Upvotes: 19

Related Questions