App is being crashed instantly after build : java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libturbomodulejsijni.so
Asked Answered
D

2

4

I was using RN V0.63.3 until this build failures happenings. I change my version to 0.63.5 and build done successfully. Now my application is being crashed instantly after build in development mode.

ERROR log :

java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libturbomodulejsijni.so SoSource 0: com.facebook.soloader.ApkSoSource[root = /data/user/0/com.zcarpet/lib-main flags = 1] SoSource 1: com.facebook.soloader.DirectorySoSource[root = ...

I upgraded my gradle version from 3.5.2 to 3.5.3 and tried these fixes :

  1. I used this code in \Android\build.gradle :
    configurations.all {
        resolutionStrategy {
            force "com.facebook.react:react-native:0.63.5" 
        }
    }
  1. Add below code in \Android\build.gridle :
    project.ext.react = [
        enableHermes: false,  // clean and rebuild if changing
        deleteDebugFilesForVariant: { false }
    ]
  1. many other fixes that could not help...

my project configurations :

    buildscript {
    ext {
        buildToolsVersion = "29.0.2"
        minSdkVersion = 21
        compileSdkVersion = 29
        targetSdkVersion = 29
    }
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath("com.android.tools.build:gradle:3.5.3")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        if (useIntlJsc) {
            implementation 'org.webkit:android-jsc-intl:+'
        } else {
            implementation 'org.webkit:android-jsc:+'
        }
    }
    }

    allprojects {
    configurations.all {
        resolutionStrategy {
            force "com.facebook.react:react-native:0.63.5" 
        }
    }
    repositories {
        google()
        jcenter()
        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")
        }

        maven { url 'https://s3.amazonaws.com/repo.commonsware.com' }
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
        maven { url 'https://www.jitpack.io' }
        maven { url "https://maven.google.com" }
        
        google()
        maven { url 'https://www.jitpack.io' }
    }
    // Workaround for https://issuetracker.google.com/117900475
    // Remove when upgrading to AGP 3.4 or higher.
    configurations.matching { it.name == '_internal_aapt2_binary' }.all { config ->
        config.resolutionStrategy.eachDependency { details ->
            details.useVersion("3.5.0-alpha03-5252756")
        }
    }
    }
Distrain answered 8/11, 2022 at 20:49 Comment(0)
M
3

Please follow below steps and check

  1. Revert back all the changes you have made after that (downgrade gradle, react-native, java & everything as like before)
  2. Delete node_modules
  3. Delete build folders (android/build & android/app/build)
  4. Recheck the package.json if the react-native version is as which was worked before (in your case 0.63.3)
  5. Run npm install or yarn to install packages
  6. Clean (remove gradle cache like mentioned here : https://mcmap.net/q/63733/-how-to-clear-gradle-cache) and rebuild the app by adding the below changes to your android/build.gradle file

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())


buildscript {
     // ...
}
    
    
allprojects {
    configurations.all {
          resolutionStrategy {
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
          }
    }
    // ...  
}

Ref: Fix and updates on Android build failures happening since Nov 4th 2022 #35210

Morganatic answered 9/11, 2022 at 7:20 Comment(5)
How to delete android/build ? by rm -rf android/build?Sokol
There is no build file but build.gradle do I need to delete that one?Sokol
it's ok if there is no build file(it mean build is already clean). Don't delete gradle files just follow remaining steps mentioned aboveMorganatic
Thank you for your attention, I did every things carefully, but app still crashes instantly after build.Distrain
I think it's because of implementation jscFlavor, when I enable hermes, error changes to realm "hermes supporting errors".Distrain
D
1

Finally I restored my November first backup, just added below code and it worked.

def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim())


buildscript {
     // ...
}
    
    
allprojects {
    configurations.all {
          resolutionStrategy {
            force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION
          }
    }
    // ...  
}
Distrain answered 10/11, 2022 at 5:36 Comment(1)
Adding the above to build.gradle also fixed for me. RN 0.64.0Foldboat

© 2022 - 2024 — McMap. All rights reserved.