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

TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[11], "react-native-screens").ScreenStack') #2115

Closed
kabundege opened this issue Apr 28, 2024 · 28 comments · Fixed by #2128
Assignees
Labels
Missing info The user didn't precise the problem enough Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided

Comments

@kabundege
Copy link

kabundege commented Apr 28, 2024

Description

Error

Error: Requiring module "node_modules/react-native-screens/src/index.tsx", which threw an exception: Error: Exception in HostObject::get(propName:RNSModule): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.app-MOOsrlTZxxpxhwDiZsIz2g==/base.apk"],nativeLibraryDirectories=[/data/app/com.app-MOOsrlTZxxpxhwDiZsIz2g==/lib/arm, /data/app/com.app-MOOsrlTZxxpxhwDiZsIz2g==/base.apk!/lib/armeabi-v7a, /system/lib, /product/lib]]] couldn't find "librnscreens.so"

Another Error

TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[11], "react-native-screens").ScreenStack')

This error is located at:
    in NativeStackViewInner (created by NativeStackView)
    in RNCSafeAreaProvider (created by SafeAreaProvider)
    in SafeAreaProvider (created by SafeAreaProviderCompat)
    in SafeAreaProviderCompat (created by NativeStackView)
    in NativeStackView (created by NativeStackNavigator)
    in PreventRemoveProvider (created by NavigationContent)
    in NavigationContent
    in Unknown (created by NativeStackNavigator)
    in NativeStackNavigator (created by Navigation)
    in ErrorBoundary (created by ErrorBoundary)
    in ErrorBoundary (created by Navigation)
    in RNGestureHandlerRootView (created by GestureHandlerRootView)
    in GestureHandlerRootView (created by Navigation)
    in Navigation (created by OptimizedComponent)
    in OptimizedComponent
    in Unknown (created by OptimizedComponent)
    in OptimizedComponent
    in Unknown (created by App)
    in EnsureSingleNavigator
    in BaseNavigationContainer
    in ThemeProvider
    in NavigationContainerInner (created by App)
    in PersistGate (created by App)
    in Provider (created by App)
    in NetworkConnectivity (created by NetworkProvider)
    in NetworkProvider (created by App)
    in _QueryClientProvider (created by App)
    in _QueryClientProvider (created by _PersistQueryClientProvider)
    in _PersistQueryClientProvider (created by App)
    in App (created by CodePushComponent)
    in CodePushComponent
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in APP(RootComponent)

Dependecies:

"dependencies": {
    "@hookform/resolvers": "^3.3.4",
    "@react-native-async-storage/async-storage": "^1.21.0",
    "@react-native-community/blur": "^4.4.0",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-native-community/netinfo": "^9.3.6",
    "@react-native-picker/picker": "^2.6.1",
    "@react-navigation/bottom-tabs": "^6.5.11",
    "@react-navigation/native": "^6.1.9",
    "@react-navigation/native-stack": "^6.9.17",
    "@react-navigation/stack": "^6.3.20",
    "@reduxjs/toolkit": "^2.1.0",
    "@tanstack/query-async-storage-persister": "^5.22.2",
    "@tanstack/react-query": "^5.20.5",
    "@tanstack/react-query-persist-client": "^5.22.2",
    "@types/metro-config": "^0.66.0",
    "appcenter": "^5.0.1",
    "appcenter-analytics": "^5.0.1",
    "appcenter-crashes": "^5.0.1",
    "axios": "^1.6.7",
    "i": "^0.3.7",
    "i18next": "^23.8.1",
    "metro-config": "^0.72.3",
    "moment": "^2.30.1",
    "moment-timezone": "^0.5.44",
    "npm": "^10.4.0",
    "react": "18.1.0",
    "react-hook-form": "^7.49.3",
    "react-i18next": "^14.0.1",
    "react-native": "0.70.10",
    "react-native-aws3": "^0.0.9",
    "react-native-bootsplash": "^5.5.3",
    "react-native-bundle-splitter": "^2.2.3",
    "react-native-calendars": "^1.1303.0",
    "react-native-code-push": "^7.1.0",
    "react-native-config": "^1.5.1",
    "react-native-date-picker": "^4.3.5",
    "react-native-device-info": "^10.12.0",
    "react-native-element-dropdown": "^2.10.1",
    "react-native-error-boundary": "^1.2.4",
    "react-native-gesture-handler": "2.8.0",
    "react-native-google-places-autocomplete": "^2.5.6",
    "react-native-image-picker": "^7.1.0",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-maps": "^1.10.0",
    "react-native-modal": "^13.0.1",
    "react-native-offline": "^6.0.2",
    "react-native-phone-number-input": "^2.1.0",
    "react-native-picker-select": "^9.0.1",
    "react-native-reanimated": "~2.2.0",
    "react-native-safe-area-context": "^4.8.2",
    "react-native-screens": "^3.29.0",
    "react-native-sensitive-info": "^5.5.8",
    "react-native-svg": "^14.1.0",
    "react-native-svg-uri": "^1.2.3",
    "react-native-toast-message": "^2.2.0",
    "react-native-vector-icons": "^10.0.3",
    "react-redux": "^9.1.0",
    "react-uuid": "^2.0.0",
    "redux": "^5.0.1",
    "redux-persist": "^6.0.0",
    "redux-thunk": "^3.1.0",
    "rn-fetch-blob": "^0.12.0",
    "yup": "^1.3.3"
  },
  "devDependencies": {
    "@babel/core": "^7.23.9",
    "@babel/runtime": "^7.23.9",
    "@react-native-community/eslint-config": "^3.2.0",
    "@tsconfig/react-native": "^3.0.3",
    "@types/jest": "^29.5.11",
    "@types/react": "^18.1.0",
    "@types/react-native": "^0.70.10",
    "@types/react-native-vector-icons": "^6.4.18",
    "@types/react-test-renderer": "^18.0.7",
    "@typescript-eslint/eslint-plugin": "^7.2.0",
    "@typescript-eslint/parser": "^7.2.0",
    "babel-jest": "^29.7.0",
    "eslint": "^8.57.0",
    "eslint-config-prettier": "^9.1.0",
    "jest": "^29.7.0",
    "metro-react-native-babel-preset": "^0.77.0",
    "prettier": "^3.2.5",
    "react-native-bundle-visualizer": "^3.1.3",
    "react-native-dotenv": "^3.4.11",
    "react-native-svg-transformer": "^1.0.0",
    "react-test-renderer": "^18.2.0",
    "typescript": "^5.3.3",
    "visualize-bundle": "^1.4.0"
  },

Steps to reproduce

  1. yarn install or yarn
  2. yarn android or npx react-native run-android

Snack or a link to a repository

here it is

Screens version

3.29.0
3.30.0+ - Since we've started using C++ layer from 3.30.0 version, original suggestion is probably incorrect. ~@tboba

React Native version

0.70.10

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

None

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

Copy link

github-actions bot commented Apr 28, 2024

Hey! 👋

It looks like you've omitted a few important sections from the issue template.

Please complete Description section.

@github-actions github-actions bot added Missing info The user didn't precise the problem enough Platform: Android This issue is specific to Android Missing repro This issue need minimum repro scenario labels Apr 28, 2024
@PhanithNoch
Copy link

Same, did you solve it?

@kabundege
Copy link
Author

Noo, am still trying to upgrade the project but it's hectic by using

  1. npx react-native upgrade or documents mutation through this guide
  2. creating a new app with the latest setup and moving the codebase to it

Same, did you solve it?

@kkafar
Copy link
Member

kkafar commented Apr 28, 2024

Hello, can we get any more context here?

After what action this started to happen? Have done something particular like version upgrade or something?

Looking at the error message it looks that something failed at the build stage as the librnscreens.so was not created / is put in wrong place / is accessed too early?

It might be hard to help you w/o reproduction.

I would start with removing all the android & gradle caches and rebuilding from scratch. Try removing android/build, android/app/build, node_modules & possible global gradle caches.

@kabundege
Copy link
Author

kabundege commented Apr 28, 2024

Hello, can we get any more context here?

After what action this started to happen? Have done something particular like version upgrade or something?

Looking at the error message it looks that something failed at the build stage as the librnscreens.so was not created / is put in wrong place / is accessed too early?

It might be hard to help you w/o reproduction.

I would start with removing all the android & gradle caches and rebuilding from scratch. Try removing android/build, android/app/build, node_modules & possible global gradle caches.

  1. after yarn install or yarn this started happening, no other kind of action was made
  2. Yes, librnscreens.so was probably removed by a recent change deployed
  3. i did all the clean possible to the point of recent a pc (starting fresh) gradle, java, yarn, ...

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided and removed Missing repro This issue need minimum repro scenario labels Apr 28, 2024
@kabundege
Copy link
Author

here is the reproduction github-repo

@usar0v
Copy link

usar0v commented Apr 29, 2024

Hello, can we get any more context here?
After what action this started to happen? Have done something particular like version upgrade or something?
Looking at the error message it looks that something failed at the build stage as the librnscreens.so was not created / is put in wrong place / is accessed too early?
It might be hard to help you w/o reproduction.
I would start with removing all the android & gradle caches and rebuilding from scratch. Try removing android/build, android/app/build, node_modules & possible global gradle caches.

  1. after yarn install or yarn this started happening, no other kind of action was made
  2. Yes, librnscreens.so was probably removed by a recent change deployed
  3. i did all the clean possible to the point of recent a pc (starting fresh) gradle, java, yarn, ...

did you solve the problem?, I have the same problem, I tried everything?

@tboba
Copy link
Member

tboba commented Apr 29, 2024

Hi everyone! Yeah, this looks like a missing librnscreens.so file. Could you check whether your project has reactNativeArchitectures property defined in gradle.properties file and that you're not running the project on device with different architecture than defined?

@kabundege
Copy link
Author

reactNativeArchitectures value in gradle.properties is

reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

@alcidesbsilvaneto
Copy link

I solved it just by using npm instead of yarn

@Dsalvat596
Copy link

Dsalvat596 commented Apr 29, 2024

I'm having the same (or a similar) issue.

Error: Exception in HostObject::get for prop 'RNSModule': java.lang.UnsatisfiedLinkError: dlopen failed: library "librnscreens.so" not found, js engine: hermes

ERROR TypeError: Cannot read property 'ScreenStack' of undefined

@Chandansharma1512
Copy link

I'm having the same (or a similar) issue.

Error: Exception in HostObject::get for prop 'RNSModule': java.lang.UnsatisfiedLinkError: dlopen failed: library "librnscreens.so" not found, js engine: hermes

ERROR TypeError: Cannot read property 'ScreenStack' of undefined

did you solve the issue?, I have the same problem.

@kabundege
Copy link
Author

A workaround that proved effective for me was to "upgrade" my application to the most recent version. This involved generating a new application using npx react-native@latest init app_name, ensuring that react-native-screens functionality was operational (which it was), and subsequently transferring my entire codebase to this updated version.

I acknowledge that this solution may not be viable for everyone, but it's worth considering nonetheless.

@kristensala
Copy link

Started having the same problem couple days back. Looks like the latest version (3.31.1) has that problem. You have "react-native-screens": "^3.29.0", try without '^'. Seemed to fix it for me right now.

@kabundege
Copy link
Author

@kabundege Did you solve this problem? I am also facing this problem.

Yes i did, refer to this reply here

A workaround that proved effective for me was to "upgrade" my application to the most recent version. This involved generating a new application using npx react-native@latest init app_name, ensuring that react-native-screens functionality was operational (which it was), and subsequently transferring my entire codebase to this updated version.

I acknowledge that this solution may not be viable for everyone, but it's worth considering nonetheless.

@Dsalvat596
Copy link

Dsalvat596 commented May 5, 2024

I'm having the same (or a similar) issue.
Error: Exception in HostObject::get for prop 'RNSModule': java.lang.UnsatisfiedLinkError: dlopen failed: library "librnscreens.so" not found, js engine: hermes
ERROR TypeError: Cannot read property 'ScreenStack' of undefined

did you solve the issue?, I have the same problem.

I actually solved it by updating my Kotlin version. Since I'm using Java jdk 17, i had to specify Kotlin 7.3.3 in gradle-wrapper.properties

@MSaaim
Copy link

MSaaim commented May 6, 2024

Started having the same problem couple days back. Looks like the latest version (3.31.1) has that problem. You have "react-native-screens": "^3.29.0", try without '^'. Seemed to fix it for me right now.

I was facing the same problem, but removing the '^' from "react-native-screens": "^3.29.0" in package.json file solved the issue. Thank you @kristensala for providing the solution.

@Chandansharma1512
Copy link

Started having the same problem couple days back. Looks like the latest version (3.31.1) has that problem. You have "react-native-screens": "^3.29.0", try without '^'. Seemed to fix it for me right now.

I was facing the same problem, but removing the '^' from "react-native-screens": "^3.29.0" in package.json file solved the issue. Thank you @kristensala for providing the solution.

use this version "react-native-screens": "3.0.0",

For me its working after downgrading it to 3.0.0.

Thanks

@cleitoncsalvagni
Copy link

Started having the same problem couple days back. Looks like the latest version (3.31.1) has that problem. You have "react-native-screens": "^3.29.0", try without '^'. Seemed to fix it for me right now.

I was facing the same problem, but removing the '^' from "react-native-screens": "^3.29.0" in package.json file solved the issue. Thank you @kristensala for providing the solution.

use this version "react-native-screens": "3.0.0",

For me its working after downgrading it to 3.0.0.

Thanks

Works for me.

@tboba tboba self-assigned this May 7, 2024
@tboba
Copy link
Member

tboba commented May 7, 2024

Let me take a look on what might cause this error.

Also, just a note from me - I would highly not recommend using 3.0.0 version of react-native-screens and consider it as a solution. This version has been published 3 years ago and is probably incompatible with the newest versions of React Native. As a temporary solution, probably using 3.29.0 version should work though.

@tboba
Copy link
Member

tboba commented May 7, 2024

I've just checked provided reproducer with a slight modifications:

  • I've removed appcenter-related dependencies, since I was unable to run my examples with them
  • I've updated React Native to 0.70.15 version

Unfortunately, I still cannot reproduce this error. However, given the information that the error comes from librnscreens.so, I've got two suspicions there:

  • Could you check which version of Android NDK do you have installed? In my case, I'm using 26.1.10909125, but newer versions should be good to go aswell. That should be the first thing you should check 👍
  • If you're trying to use react-navigation's native-stack, are you trying to use goBackGesture prop? If so, please keep in mind that this prop is still not introduced there, since the PR with adding the API to native-stack is still open. For now, you can stick with the native-stack v5 (if possible).

@kkafar kkafar self-assigned this May 7, 2024
@kristensala
Copy link

@tboba Yup. Android NDK is the problem. Solved. Thanks

@kabundege
Copy link
Author

kabundege commented May 7, 2024

@kristensala kindly share with us your android/build.gradle changes,
if it's where the NDK change were made.

buildscript {
    ext {
        buildToolsVersion = "31.0.0"
        minSdkVersion = 21
        compileSdkVersion = 32
        targetSdkVersion = 32

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888" // over here
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529" // & over here
        }
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.2.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("de.undercouch:gradle-download-task:5.0.1")
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

@kristensala
Copy link

kristensala commented May 7, 2024

@kabundege I removed the If/else around ndkVersion and just added the ndkVersion = "26....."
It can have a bit of a snowball effect after. You might have to update other packages and/or react-native version itself

@kkafar
Copy link
Member

kkafar commented May 7, 2024

Hello 👋🏻 here come some conclusions

The error:

Error: Requiring module "node_modules/react-native-screens/src/index.tsx", which threw an exception: Error: Exception in HostObject::get(propName:RNSModule): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.app-MOOsrlTZxxpxhwDiZsIz2g==/base.apk"],nativeLibraryDirectories=[/data/app/com.app-MOOsrlTZxxpxhwDiZsIz2g==/lib/arm, /data/app/com.app-MOOsrlTZxxpxhwDiZsIz2g==/base.apk!/lib/armeabi-v7a, /system/lib, /product/lib]]] couldn't find "librnscreens.so"

Is indeed triggered by not present libscreens.so shared object and the fault is on library side, in particular these lines in our build.gradle which basically means that unless you are on React Native 0.71 or newer it won't be build, resulting in this runtime crash.

This issue is an oversight on our side as we should either change compatibility note or add some checks for RN version in runtime to avoid loading the dll into JVM.

Workarounds

If it is feasible in your situation / application you can upgrade React Native to 0.71 or newer and this should resolve the issue.

Another option is temporary downgrade and wait for fix on our side, however note that we are unsure yet on how to proceed with this issue (some technical constraints) and it might take a while. 3.29.0 should be the last unaffected version.

@gui-grana
Copy link

@kristensala I've downgraded RN Screens to 3.29.0 and it fixed my problem for now. Thank you!

piaskowyk added a commit that referenced this issue May 13, 2024
## Description

Fixes
#2115

The `System.loadLibrary("rnscreens")` can throw an exception that
inherits from the `Error` class instead of the `Exception` class.
@kkafar
Copy link
Member

kkafar commented May 13, 2024

Hey, we've found better way to handle this issue => should be solved with next release.

@MurariCrimsonbeans
Copy link

Started having the same problem couple days back. Looks like the latest version (3.31.1) has that problem. You have "react-native-screens": "^3.29.0", try without '^'. Seemed to fix it for me right now.

This fixed my problem

ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this issue Oct 9, 2024
## Description

Fixes
software-mansion#2115

The `System.loadLibrary("rnscreens")` can throw an exception that
inherits from the `Error` class instead of the `Exception` class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing info The user didn't precise the problem enough Platform: Android This issue is specific to Android Repro provided A reproduction with a snack or repo is provided
Projects
None yet