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

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

Open kabundege opened this issue 9 months ago • 26 comments

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

kabundege avatar Apr 28 '24 00:04 kabundege

Hey! 👋

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

Please complete Description section.

github-actions[bot] avatar Apr 28 '24 00:04 github-actions[bot]

Same, did you solve it?

PhanithNoch avatar Apr 28 '24 12:04 PhanithNoch

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?

kabundege avatar Apr 28 '24 16:04 kabundege

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.

kkafar avatar Apr 28 '24 18:04 kkafar

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, ...

kabundege avatar Apr 28 '24 19:04 kabundege

here is the reproduction github-repo

kabundege avatar Apr 28 '24 21:04 kabundege

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?

usar0v avatar Apr 29 '24 05:04 usar0v

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?

tboba avatar Apr 29 '24 08:04 tboba

reactNativeArchitectures value in gradle.properties is

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

kabundege avatar Apr 29 '24 08:04 kabundege

I solved it just by using npm instead of yarn

alcidesbsilvaneto avatar Apr 29 '24 13:04 alcidesbsilvaneto

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

Dsalvat596 avatar Apr 29 '24 23:04 Dsalvat596

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.

Chandansharma1512 avatar May 01 '24 06:05 Chandansharma1512

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.

kabundege avatar May 01 '24 10:05 kabundege

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.

kristensala avatar May 03 '24 11:05 kristensala

@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.

kabundege avatar May 05 '24 12:05 kabundege

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

Dsalvat596 avatar May 05 '24 15:05 Dsalvat596

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.

MSaaim avatar May 06 '24 10:05 MSaaim

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

Chandansharma1512 avatar May 06 '24 13:05 Chandansharma1512

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.

cleitoncsalvagni avatar May 06 '24 18:05 cleitoncsalvagni

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 avatar May 07 '24 07:05 tboba

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).

tboba avatar May 07 '24 09:05 tboba

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

kristensala avatar May 07 '24 09:05 kristensala

@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
    }
}

kabundege avatar May 07 '24 10:05 kabundege

@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

kristensala avatar May 07 '24 10:05 kristensala

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.

kkafar avatar May 07 '24 10:05 kkafar

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

gui-grana avatar May 08 '24 18:05 gui-grana

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

kkafar avatar May 13 '24 08:05 kkafar

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

MurariCrimsonbeans avatar May 14 '24 07:05 MurariCrimsonbeans