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

java.lang.UnsatisfiedLinkError: dlopen failed: library "libappmodules.so" not found #38467

Closed
prince-sugarfit opened this issue Jul 17, 2023 · 19 comments
Assignees
Labels
Needs: Attention Issues where the author has responded to feedback. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)

Comments

@prince-sugarfit
Copy link

Description

Getting below error in android after upgrading to react-native version 0.72.3. App builds successfully and when I open app it crashes on native side.

FATAL EXCEPTION: main
Process: fit.sugar.android.debug, PID: 17748
java.lang.UnsatisfiedLinkError: dlopen failed: library "libappmodules.so" not found
at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
at java.lang.System.loadLibrary(System.java:1664)
at com.facebook.soloader.nativeloader.SystemDelegate.loadLibrary(SystemDelegate.java:24)
at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:52)
at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:30)
at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:869)
at com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load(DefaultNewArchitectureEntryPoint.kt:41)
at com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load$default(DefaultNewArchitectureEntryPoint.kt:27)
at com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load(Unknown Source:2)
at fit.cure.android.MainApplication.onCreate(MainApplication.java:89)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

React Native Version

0.72.3

Output of npx react-native info

System:
OS: macOS 13.0.1
CPU: (10) arm64 Apple M1 Pro
Memory: 108.11 MB / 16.00 GB
Shell:
version: 5.8.1
path: /bin/zsh
Binaries:
Node:
version: 16.14.0
path: ~/.nvm/versions/node/v16.14.0/bin/node
Yarn:
version: 1.22.17
path: /opt/homebrew/bin/yarn
npm:
version: 8.3.1
path: ~/.nvm/versions/node/v16.14.0/bin/npm
Watchman:
version: 2023.07.10.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.12.1
path: /opt/homebrew/bin/pod
SDKs:
iOS SDK: Not Found
Android SDK:
API Levels:
- "19"
- "28"
- "29"
- "30"
- "31"
- "32"
- "33"
- "34"
Build Tools:
- 28.0.3
- 29.0.2
- 30.0.1
- 30.0.2
- 30.0.3
- 31.0.0
- 32.0.0
- 33.0.0
- 33.0.1
- 33.0.2
System Images:
- android-29 | Intel x86 Atom_64
- android-29 | Google APIs Intel x86 Atom
- android-30 | Google APIs ARM 64 v8a
- android-31 | Google APIs ARM 64 v8a
Android NDK: 23.1.7779620
IDEs:
Android Studio: 2020.3 AI-203.7717.56.2031.7935034
Xcode:
version: /undefined
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.12
path: /opt/homebrew/opt/openjdk@11/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.72.3
wanted: 0.72.3
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: false

Steps to reproduce

Upgraded my application react native version from 0.66.3 to 0.72.3
Apply all the changes suggested in upgrade helper

Snack, code example, screenshot, or link to a repository

Here is my build.gradle file,

apply plugin: "com.android.application"
apply plugin: "nebula.dependency-lock"
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
apply plugin: "com.facebook.react"

apply from: "../../node_modules/@sentry/react-native/sentry.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
apply from: "./env.gradle"

/**
 * This is the configuration block to customize your React Native Android app.
 * By default you don't need to apply any configuration, just uncomment the lines you need.
 */
react {
    /* Folders */
    //   The root of your project, i.e. where "package.json" lives. Default is '..'
    // root = file("../../")
    //   The folder where the react-native NPM package is. Default is ../node_modules/react-native
    // reactNativeDir = file("../node_modules/react-native")
    //   The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
    // codegenDir = file("../node_modules/@react-native/codegen")
    //   The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
    // cliFile = file("../node_modules/react-native/cli.js")
    /* Variants */
    //   The list of variants to that are debuggable. For those we're going to
    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    debuggableVariants = ["debugSugarfit"]
    /* Bundling */
    //   A list containing the node command and its flags. Default is just 'node'.
    // nodeExecutableAndArgs = ["node"]
    //
    //   The command to run when bundling. By default is 'bundle'
    // bundleCommand = "ram-bundle"
    //
    //   The path to the CLI configuration file. Default is empty.
    // bundleConfig = file(../rn-cli.config.js)
    //
    //   The name of the generated asset file containing your JS bundle
    // bundleAssetName = "MyApplication.android.bundle"
    //
    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    // entryFile = file("../js/MyApplication.android.js")
    //
    //   A list of extra flags to pass to the 'bundle' commands.
    //   See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
    // extraPackagerArgs = []
    /* Hermes Commands */
    //   The hermes compiler command to run. By default it is 'hermesc'
    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
    //
    //   The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
    // hermesFlags = ["-O", "-output-source-map"]
}

/**
 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
 */
def enableProguardInReleaseBuilds = true
/**
 * The preferred build flavor of JavaScriptCore (JSC)
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US. Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Run Proguard to shrink the Java bytecode in release builds.
 */

android {

    // dynamicFeatures = [":twilioVideo"]
    ndkVersion rootProject.ext.ndkVersion

    configurations.all {
        exclude group: 'com.facebook.react:react-native'
    }

    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion buildToolsVersion
    namespace 'fit.cure.android'
    defaultConfig {
        applicationId = project.env.get("BUNDLE_ID")
        minSdkVersion rootProject.ext.minSDKVersion
        targetSdkVersion rootProject.ext.targetSDKVersion
        versionCode = project.env.get("BUILD_VERSION").toInteger()
        versionName = project.env.get("APP_VERSION")
        archivesBaseName = "${project.env.get("APP_ID")}-$versionName"
        missingDimensionStrategy 'react-native-camera', 'general'
        multiDexEnabled true
        resConfigs "en"
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
        vectorDrawables.useSupportLibrary = true
        resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
    }

    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "4g" //specify the heap size for the dex process
    }
    lintOptions {
        disable 'MissingTranslation'
        checkReleaseBuilds false
        abortOnError false
    }
    
    kotlinOptions {
        jvmTarget = "11"
    }

    signingConfigs {
        debug {
            storeFile file(CUREFIT_DEBUG_STORE_FILE)
            storePassword CUREFIT_DEBUG_STORE_PASSWORD
            keyAlias CUREFIT_DEBUG_KEY_ALIAS
            keyPassword CUREFIT_DEBUG_KEY_PASSWORD
        }
        release {
            storeFile file(CUREFIT_RELEASE_STORE_FILE)
            storePassword CUREFIT_RELEASE_STORE_PASSWORD
            keyAlias CUREFIT_RELEASE_KEY_ALIAS
            keyPassword CUREFIT_RELEASE_KEY_PASSWORD
        }
        debugSugarfit {
          storeFile file(SUGARFIT_DEBUG_STORE_FILE)
          storePassword SUGARFIT_DEBUG_STORE_PASSWORD
          keyAlias SUGARFIT_DEBUG_KEY_ALIAS
          keyPassword SUGARFIT_DEBUG_KEY_PASSWORD
        }
        releaseSugarfit {
          storeFile file(SUGARFIT_RELEASE_STORE_FILE)
          storePassword SUGARFIT_RELEASE_STORE_PASSWORD
          keyAlias SUGARFIT_RELEASE_KEY_ALIAS
          keyPassword SUGARFIT_RELEASE_KEY_PASSWORD
        }
    }

    bundle {
        language {
            enableSplit = true
        }
        density {
            enableSplit = true
        }
        abi {
            enableSplit = true
        }
    }

    buildTypes {
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
            proguardFile 'proguard-rules.pro'
            resValue "string", "CodePushDeploymentKey", project.env.get("CODEPUSH_KEY_RELEASE")
            resValue "string", "sync_account_type", project.env.get("BUNDLE_ID")
            resValue "string", "content_authority", "${project.env.get('BUNDLE_ID')}.provider"
            resValue "string", "file_content_authority", "${project.env.get('BUNDLE_ID')}.file.provider"
            buildConfigField "String", "SYNC_ACCOUNT_TYPE", CUREFIT_RELEASE_SYNC_ACCOUNT_TYPE
            buildConfigField "String", "CONTENT_AUTHORITY", CUREFIT_RELEASE_CONTENT_AUTHORITY
            buildConfigField "String", "FILE_CONTENT_AUTHORITY", CUREFIT_RELEASE_FILE_CONTENT_AUTHORITY
            resValue "string", "sensor_data_content_provider", "${project.env.get('BUNDLE_ID')}.provider"
            resValue "string", "app_name", project.env.get("APP_NAME")
            resValue "string", "tray__authority", android.defaultConfig.applicationId + ".tray"
        }
        //debug code push key should be empty
        debug {
            proguardFile 'proguard-rules.pro'
            applicationIdSuffix ".debug"
            signingConfig signingConfigs.debug
            resValue "string", "CodePushDeploymentKey", project.env.get("CODEPUSH_KEY_DF")
            resValue "string", "sync_account_type", "${project.env.get('BUNDLE_ID')}.debug"
            resValue "string", "content_authority", "${project.env.get('BUNDLE_ID')}.debug.provider"
            resValue "string", "file_content_authority", "${project.env.get('BUNDLE_ID')}.debug.file.provider"
            buildConfigField "String", "SYNC_ACCOUNT_TYPE", CUREFIT_DEBUG_SYNC_ACCOUNT_TYPE
            buildConfigField "String", "CONTENT_AUTHORITY", CUREFIT_DEBUG_CONTENT_AUTHORITY
            buildConfigField "String", "FILE_CONTENT_AUTHORITY", CUREFIT_DEBUG_FILE_CONTENT_AUTHORITY
            resValue "string", "app_name", "${project.env.get('APP_NAME')}-debug"
            resValue "string", "tray__authority", (android.defaultConfig.applicationId + ".debug.tray")
            matchingFallbacks = ['debug', 'release', 'stage']
        }
        releaseSugarfit {
          minifyEnabled enableProguardInReleaseBuilds
          proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
          signingConfig signingConfigs.releaseSugarfit
          proguardFile 'proguard-rules.pro'
          resValue "string", "CodePushDeploymentKey", project.env.get("CODEPUSH_KEY_RELEASE")
          resValue "string", "sync_account_type", project.env.get("BUNDLE_ID")
          resValue "string", "content_authority", "${project.env.get('BUNDLE_ID')}.provider"
          resValue "string", "file_content_authority", "${project.env.get('BUNDLE_ID')}.file.provider"
          buildConfigField "String", "SYNC_ACCOUNT_TYPE", SUGARFIT_RELEASE_SYNC_ACCOUNT_TYPE
          buildConfigField "String", "CONTENT_AUTHORITY", SUGARFIT_RELEASE_CONTENT_AUTHORITY
          buildConfigField "String", "FILE_CONTENT_AUTHORITY", SUGARFIT_RELEASE_FILE_CONTENT_AUTHORITY
          resValue "string", "sensor_data_content_provider", "${project.env.get('BUNDLE_ID')}.provider"
          resValue "string", "app_name", project.env.get("APP_NAME")
          resValue "string", "tray__authority", android.defaultConfig.applicationId + ".tray"
          matchingFallbacks = ['release']
        }
        //debug code push key should be empty
        debugSugarfit {
          proguardFile 'proguard-rules.pro'
          applicationIdSuffix ".debug"
          debuggable true
          signingConfig signingConfigs.debugSugarfit
          resValue "string", "CodePushDeploymentKey", project.env.get("CODEPUSH_KEY_DF")
          resValue "string", "sync_account_type", "${project.env.get('BUNDLE_ID')}.debug"
          resValue "string", "content_authority", "${project.env.get('BUNDLE_ID')}.debug.provider"
          resValue "string", "file_content_authority", "${project.env.get('BUNDLE_ID')}.debug.file.provider"
          buildConfigField "String", "SYNC_ACCOUNT_TYPE", SUGARFIT_DEBUG_SYNC_ACCOUNT_TYPE
          buildConfigField "String", "CONTENT_AUTHORITY", SUGARFIT_DEBUG_CONTENT_AUTHORITY
          buildConfigField "String", "FILE_CONTENT_AUTHORITY", SUGARFIT_DEBUG_FILE_CONTENT_AUTHORITY
          resValue "string", "app_name", "${project.env.get('APP_NAME')} (Debug)"
          resValue "string", "tray__authority", (android.defaultConfig.applicationId + ".debug.tray")
          matchingFallbacks = ['debug', 'stage', 'release']
        }
    }

    aaptOptions {
        noCompress "tflite"
        noCompress "lite"
    }
      packagingOptions {
        // Required by Qualcomm SNPE SDK: snpe-release & platform-validator
        // https://developer.qualcomm.com/docs/snpe/android_tutorial.html
        pickFirst 'lib/armeabi-v7a/libsymphony-cpu.so'
        pickFirst 'lib/arm64-v8a/libsymphony-cpu.so'

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

        pickFirst '**/x86/libjsc.so'
        pickFirst '**/armeabi-v7a/libjsc.so'
        pickFirst '**/x86_64/libjsc.so'
        pickFirst '**/arm64-v8a/libjsc.so'

        pickFirst '**/*.so'
  }
  externalNativeBuild {
    cmake {
      path "src/main/cpp/CMakeLists.txt"
      version "3.10.2"
    }
  }

  compileOptions {
    sourceCompatibility 11
    targetCompatibility 11
  }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.30"

    // camerax
    def camerax_version = '1.0.0-rc01'
    def camerax_view_version = '1.0.0-alpha20'
    implementation "androidx.camera:camera-core:${camerax_version}"
    implementation "androidx.camera:camera-camera2:${camerax_version}"
    implementation "androidx.camera:camera-lifecycle:${camerax_version}"
    implementation "androidx.camera:camera-view:${camerax_view_version}"

    //mlkit
    def mlkit_version = "16.0.3"
    implementation "com.google.mlkit:face-detection:${mlkit_version}"

    //socket
    implementation "com.neovisionaries:nv-websocket-client:2.4"

    //opencv
    def opencv_version = '4.3.0'
    implementation "com.github.iamareebjamal:opencv-android:${opencv_version}"

    // Add the Firebase Crashlytics SDK.
    implementation 'com.google.firebase:firebase-crashlytics:18.2.6'
    // Recommended: Add the Google Analytics SDK.
    implementation 'com.google.firebase:firebase-analytics:20.0.1'

    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }

   implementation project(':twilioVideo')
   implementation "com.twilio:video-android:7.6.3"

    implementation "androidx.appcompat:appcompat:1.2.0"
    implementation "androidx.constraintlayout:constraintlayout:2.0.4"
    implementation 'in.juspay:hypersdk:2.1.6-rc.01'
    implementation project(':PayWithAmazon')
    implementation project(':react-native-system-setting')
    implementation 'com.airbnb.android:lottie:3.0.7'
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.google.android.flexbox:flexbox:3.0.0'
    implementation 'com.android.volley:volley:1.2.1'
    implementation 'com.github.checkout:frames-android:v2.0.5'
    implementation 'com.android.installreferrer:installreferrer:2.1'

    implementation(project(':lottie-react-native')) {
        exclude group: "com.airbnb.android:lottie"
    }

    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation "phonepe.intentsdk.android.release:IntentSDK:0.1.5"
    implementation files('libs/PGSDK_v1.0.1.jar')

    implementation 'commons-io:commons-io:2.6'
    implementation 'net.grandcentrix.tray:tray:0.11.1'
    implementation "com.google.firebase:firebase-messaging:23.0.0"
    implementation "com.google.android.gms:play-services-base:18.0.1"
    implementation "com.google.android.gms:play-services-cast-framework:21.0.0"
    implementation 'com.1gravity:android-contactpicker:1.3.2'
    implementation "com.twilio:accessmanager-android:0.1.0"
    implementation 'androidx.work:work-runtime:2.8.0'
    implementation 'androidx.work:work-runtime-ktx:2.8.0'
    implementation("com.twilio:chat-android:7.0.1") {
        exclude group: "org.apache.directory.studio"
    }
    implementation ("com.google.android.gms:play-services-location:19.0.0")

    // For animated GIF support

    implementation 'com.google.android.play:core:1.9.0'

    implementation "android.arch.lifecycle:extensions:1.1.1"
    implementation(project(':react-native-pose-estimation')) {
        exclude group: "com.google.android.exoplayer"
    }
    implementation 'com.facebook.fresco:fresco:2.6.0'   // for rendering gifs
    implementation 'com.facebook.fresco:animated-webp:2.6.0'
    implementation 'com.facebook.fresco:webpsupport:2.6.0'
    implementation 'com.android.billingclient:billing:4.1.0'
}

apply plugin: "com.google.gms.google-services"

apply plugin: 'com.google.firebase.crashlytics'

apply plugin: 'hypersdk-asset-plugin'

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); 
applyNativeModulesAppBuildGradle(project)

@prince-sugarfit prince-sugarfit added Needs: Triage 🔍 Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules) labels Jul 17, 2023
@cortinico
Copy link
Contributor

newArchEnabled: true

Is the app working fine with the New Architecture disabled?

@prince-sugarfit
Copy link
Author

prince-sugarfit commented Jul 17, 2023

With newArchEnabled: false getting below error with hermes

FATAL EXCEPTION: main Process: fit.sugar.android.debug, PID: 9217 java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/data/app/~~wBRnOgkRICzGO4BLfVoAMQ==/fit.sugar.android.debug-4Iz96fqmd7Q57SPS7ZAjBw==/base.apk!/lib/arm64-v8a/libfolly_runtime.so"... at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at com.facebook.soloader.nativeloader.SystemDelegate.loadLibrary(SystemDelegate.java:24) at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:52) at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:30) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:869) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:26) at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:24) at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:379) at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:325) at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:96) at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:42) at com.facebook.react.ReactDelegate.loadApp(ReactDelegate.java:121) at com.facebook.react.ReactActivityDelegate.loadApp(ReactActivityDelegate.java:114) at com.facebook.react.ReactActivityDelegate.onCreate(ReactActivityDelegate.java:109) at com.facebook.react.ReactActivity.onCreate(ReactActivity.java:46) at fit.cure.android.MainActivity.onCreate(MainActivity.java:59) at android.app.Activity.performCreate(Activity.java:7994) at android.app.Activity.performCreate(Activity.java:7978) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jul 17, 2023
@cortinico
Copy link
Contributor

With newArchEnabled: true getting other error with hermes

Can you clarify which error are you getting with which flag? @prince-sugarfit

@cortinico cortinico removed the Needs: Attention Issues where the author has responded to feedback. label Jul 17, 2023
@prince-sugarfit
Copy link
Author

Sorry, for newArchEnabled: false getting error mentioned in last comment. Updated the comment

@cortinico cortinico added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Jul 17, 2023
@cortinico
Copy link
Contributor

Can we get a reproducer?

@github-actions
Copy link

⚠️ Missing Reproducible Example
ℹ️ It looks like your issue is missing a reproducible example. Please provide either:

@prince-sugarfit
Copy link
Author

prince-sugarfit commented Jul 17, 2023

By creating a new react native project and putting the things from current project, I've found that below part of app/build.gradle is creating a problem.

externalNativeBuild { cmake { path "src/main/cpp/CMakeLists.txt" version "3.10.2" } }

Can anyone help me?

Here is my CMake file

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.10.2)

# Declares and names the project.

project("sugarfit")

# Creates and names a library, sets it as either STATIC
# or SHARED, and provides the relative paths to its source code.
# You can define multiple libraries, and CMake builds them for you.
# Gradle automatically packages shared libraries with your APK.

add_library( # Sets the name of the library.
        commander-lib

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        commander-lib.cpp)

# Searches for a specified prebuilt library and stores the path as a
# variable. Because CMake includes system libraries in the search path by
# default, you only need to specify the name of the public NDK library
# you want to add. CMake verifies that the library exists before
# completing its build.

find_library( # Sets the name of the path variable.
              log-lib

              # Specifies the name of the NDK library that
              # you want CMake to locate.
              log )

# Specifies libraries CMake should link to your target library. You
# can link multiple libraries, such as libraries you define in this
# build script, prebuilt third-party libraries, or system libraries.

target_link_libraries( # Specifies the target library.
                        commander-lib

                       # Links the target library to the log library
                       # included in the NDK.
                       ${log-lib} )

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Jul 17, 2023
@prince-sugarfit
Copy link
Author

@cortinico Do you know how can I merge these two CMakeLists?

  1. React-Android (For new architecture)
  2. Project has custom c++ library

@vtn-dev-manish
Copy link

I am having same requirement. Thanks for asking.

@cortinico
Copy link
Contributor

@cortinico Do you know how can I merge these two CMakeLists?

Can you @prince-sugarfit or @vtn-dev-manish provide a reproducer project with the linked template: https://github.com/react-native-community/reproducer-react-native

It's extremely hard to help you without

@prince-sugarfit
Copy link
Author

@cortinico Please find this reproducer project
https://github.com/prince-sugarfit/rn-android-reproducer

I have added cpp lib to the base template & enabled the new architecture, check the last commit

@cortinico cortinico added Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. and removed Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Jul 25, 2023
@prince-sugarfit
Copy link
Author

prince-sugarfit commented Jul 28, 2023

I could fix it & run the project by copying OnLoad.cpp & CMakeLists.txt from node_modules -> react-native -> ReactAndroid to root android project and merged my cpp library in the same CMakeList file

But, looking for other better way.

@cortinico cortinico self-assigned this Nov 27, 2023
@cortinico
Copy link
Contributor

Hey @prince-sugarfit
I'm sorry but only now I had the time to look into this.
The reproducer you provided builds and runs correctly on either newArchEnabled: false and newArchEnabled: true.

The CI on the reproducer, which builds the project, is also green so I'm unsure what is your problem. Please let me know

@cortinico cortinico added Needs: Author Feedback and removed Needs: Attention Issues where the author has responded to feedback. Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. labels Nov 27, 2023
@prince-sugarfit
Copy link
Author

@cortinico Thank you for your response.

Yes, It builds successfully but as soon as app opens it crashes with mentioned error. Did you try running locally with metro server on?

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Nov 27, 2023
@cortinico
Copy link
Contributor

Ah I understand what's going on. The Default* classes assume you'll have a libappmodules.so built. If you override the CMake file (as you do in your reproducer), you need to make sure appmodules is produced correctly.

You should be fine by updating the CMakeLists.txt file as follows:

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.10.2)

# Declares and names the project.

-project("sugarfit")
+project(appmodules)

+# This file includes all the necessary to let you build your application with the New Architecture.
+include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake)

@cortinico
Copy link
Contributor

Closing as answered

@djindal61
Copy link

Hi @cortinico
I am facing the same issue. I am migrating the RN V from 0.70.7 to RN V 0.72.4
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/data/app/~~3sZ6beNcq9AmZc2AhbJYsg==/com.marylandhealthconnection.mobile-VF_5z6Tx7l8gWP22f1sh6g==/lib/arm64/libfolly_runtime.so"... at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at com.facebook.soloader.nativeloader.SystemDelegate.loadLibrary(SystemDelegate.java:24) at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:52) at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:30) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:869) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:26) at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:24) at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:379) at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:325) at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:96) at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:42) at com.marylandhealthconnection.mobile.MainApplication.onCreate(MainApplication.java:104) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712) at android.app.ActivityThread.access$1300(ActivityThread.java:237) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 2024-01-23 12:09:12.789 5718-5761 FirebaseCrashlytics com.marylandhealthconnection.mobile W Unable to read App Quality Sessions session id.

image

@Rishi-Setpal-TSS
Copy link

Hi @cortinico I am facing the same issue. I am migrating the RN V from 0.70.7 to RN V 0.72.4 java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__emutls_get_address" referenced by "/data/app/~~3sZ6beNcq9AmZc2AhbJYsg==/com.marylandhealthconnection.mobile-VF_5z6Tx7l8gWP22f1sh6g==/lib/arm64/libfolly_runtime.so"... at java.lang.Runtime.loadLibrary0(Runtime.java:1087) at java.lang.Runtime.loadLibrary0(Runtime.java:1008) at java.lang.System.loadLibrary(System.java:1664) at com.facebook.soloader.nativeloader.SystemDelegate.loadLibrary(SystemDelegate.java:24) at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:52) at com.facebook.soloader.nativeloader.NativeLoader.loadLibrary(NativeLoader.java:30) at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:869) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:26) at com.facebook.hermes.reactexecutor.HermesExecutor.<clinit>(HermesExecutor.java:20) at com.facebook.hermes.reactexecutor.HermesExecutor.loadLibrary(HermesExecutor.java:24) at com.facebook.react.ReactInstanceManagerBuilder.getDefaultJSExecutorFactory(ReactInstanceManagerBuilder.java:379) at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:325) at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:96) at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:42) at com.marylandhealthconnection.mobile.MainApplication.onCreate(MainApplication.java:104) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1192) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6712) at android.app.ActivityThread.access$1300(ActivityThread.java:237) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) 2024-01-23 12:09:12.789 5718-5761 FirebaseCrashlytics com.marylandhealthconnection.mobile W Unable to read App Quality Sessions session id.

image

Did you Solved?
and How ?

@flyskywhy
Copy link
Contributor

No need to rebuild third-party .aar or .so, just patch:

cd tools/android-sdk/ndk

mv ./21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so ./21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/origin_libc++_shared.so
cp ./23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so ./21.4.7075529/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/

as described in Patch to fix __emutls_get_address crash on Android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Attention Issues where the author has responded to feedback. Type: New Architecture Issues and PRs related to new architecture (Fabric/Turbo Modules)
Projects
None yet
Development

No branches or pull requests

6 participants