React Native : Error cannot find symbol com.swmansion.gesturehandler.react.RNGestureHandlerPackage - react-native

I know that many related problems already asked but still none of them worked.
Error :
> Configure project :react-native-firebase_firestore
:react-native-firebase_firestore package.json found at /home/username/StudioProjects/agl-admin/node_modules/#react-native-firebase/firestore/package.json......
> Task :app:compileDebugJavaWithJavac FAILED
/home/username/StudioProjects/agl-admin/android/app/src/main/java/com/agladmin/MainApplication.java:12: error: cannot find symbol
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
^
symbol: class RNGestureHandlerPackage
location: package com.swmansion.gesturehandler.react
/home/username/StudioProjects/agl-admin/android/app/src/main/java/com/agladmin/MainApplication.java:49: error: cannot find symbol
packages.add(new RNGestureHandlerPackage());
^
symbol: class RNGestureHandlerPackage
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
....
Most Matching Question : " com.swmansion.gesturehandler.react" ERROR APPEARS
package.json
{
"name": "agl-admin",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web"
},
"dependencies": {
"#expo-google-fonts/poppins": "^0.2.2",
"#react-native-firebase/app": "^14.5.1",
"#react-native-firebase/firestore": "^14.5.1",
"#react-navigation/drawer": "^6.3.1",
"#react-navigation/native": "^6.0.8",
"#react-navigation/stack": "^6.1.1",
"expo": "~44.0.2",
"expo-app-loading": "^1.3.0",
"expo-font": "~10.0.4",
"expo-splash-screen": "~0.14.1",
"expo-status-bar": "~1.2.0",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-gesture-handler": "^2.3.2",
"react-native-paper": "^4.11.2",
"react-native-reanimated": "^2.4.1",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "~3.10.1",
"react-native-splash-screen": "^3.3.0",
"react-native-web": "0.17.1",
"react-navigation": "^4.4.4"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}
What I've :
In android\settings.gradle include ':react-native.... these two where already there
In MainAplication.java import com.swmansion.gesturehandler.react.RNGestureHandlerPackage; already there
and new RNGestureHandlerPackage() List was not there so i added.
rm -rf node_modules
npm cache clean --force
./gradlew clean
and then reinstall all.
=============== UPDATE =================
I fixed it by React downgrading to "react-native-gesture-handler": "~2.1.3"
and resting cache. T

In the new version (RNGH 2) you have to remove .react, so it's just import com.swmansion.gesturehandler.RNGestureHandlerPackage;!

Make sure added you add react-native-reanimated plugin into babel.config.js
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: ['react-native-reanimated/plugin'],
};

Related

Object is not a function in Expo(react-native) app

My App is not starting. Please help me. Is that the problem with the libraryies ot with the code?
edit 1:
another mistake when doing render
Error: Problem validating fields in app.json. See https://docs.expo.io/workflow/configuration/
• should NOT have additional property 'nodeModulesPath'.
app.json file:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"#expo/vector-icons": "^12.0.4",
"#react-native-community/masked-view": "^0.1.10",
"#react-navigation/bottom-tabs": "^5.11.10",
"#react-navigation/native": "^5.9.4",
"expo": "~41.0.1",
"expo-status-bar": "~1.0.4",
"firebase": "^8.2.3",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^1.13.2",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^3.0.0",
"react-native-stack": "^1.0.0-alpha11",
"react-native-web": "~0.13.12",
"react-navigation": "^4.4.4",
"react-navigation-stack": "^2.10.4"
},
"devDependencies": {
"#babel/core": "^7.9.0"
},
"private": true
}
edit 2:
I uninstalled react-native-stack, but there is a mistake: Error: Module not found: Can't resolve 'react-native-stack'
I installed it again:
npm install react-native-stack
Then I have the same problem in the render (look the first picture) and this mistakes in console:
1 (yellow)
`Some of your project's dependencies are not compatible with currently installed expo package version:
- react-native-reanimated - expected version range: ~2.1.0 - actual version installed: ^1.13.2
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo install [package-name ...]`
2 (red)
`Error: Problem validating fields in app.json. See https://docs.expo.io/workflow/configuration/
• should NOT have additional property 'nodeModulesPath'.`
The render answer:
`√ Expo Webpack
Compiled successfully in 5.25s
i 「wds」: Project is running at http://0.0.0.0:19006/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from C:\Users\Лёха\AppData\Roaming\npm\node_modules\expo-cli\node_modules\#expo\webpack-config\web-default
i 「wds」: 404s will fallback to /
edit 3
I was wrong, so I deleted react-native-stack again
npm uninstall react-native-stack
Then I deleted the import in App.js file:
import {createStackNavigator} from 'react-native-stack'
I still have it in yarn.lock file, but I think rm -rf node_modules should work. I just don't understand, how to use it.
`
EDIT
you are probably not having react-native-screens in your node_modules? For react-navigation for each module you are using you have other modules that you need to import in addition. This is not done automatically.
old answer
You are using useScreens() outside of a component. By the way useScreens() is deprecated and should be replaced with enableScreens

why the app doesnt works after install react native navigation module?

well, there is no error before I executed this command: "npm install #react-navigation/native". After I installed this module, when I execute app in android emulator react native app doesnt works. there is no problem on my node.js, npm, android_home,android sdk.
BUILD FAILED in 10s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:preDebugBuild'.
Could not resolve all files for configuration ':app:debugCompileClasspath'.
Failed to transform artifact 'react-native-reanimated-61.aar (project :react-native-reanimated)' to match attributes {artifactType=android-manifest}.
> Execution failed for JetifyTransform: C:\Users\JohnH\Desktop\ReactNative Coding\ReactNative\react_native_navigation_01\node_modules\react-native-reanimated\android\react-native-reanimated-61.aar.
> Failed to transform 'C:\Users\JohnH\Desktop\ReactNative Coding\ReactNative\react_native_navigation_01\node_modules\react-native-reanimated\android\react-native-reanimated-61.aar' using Jetifier. Reason: Cannot open a library at 'FileMapping(from=C:\Users\JohnH\Desktop\ReactNative Coding\ReactNative\react_native_navigation_01\node_modules\react-native-reanimated\android\react-native-reanimated-61.aar, to=C:\Users\JohnH\Desktop\ReactNative Coding\ReactNative\react_native_navigation_01\node_modules\react-native-reanimated\android\build.transforms\c66aa8e9da80f2493bdea3fa761dc58e\jetified-react-native-reanimated-61.aar)'. (Run with --stacktrace for more details.)
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 10s
at checkExecSyncError (child_process.js:616:11)
at execFileSync (child_process.js:634:13)
at runOnAllDevices (C:\Users\JohnH\Desktop\ReactNative Coding\ReactNative\react_native_navigation_01\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:39)
at buildAndRun (C:\Users\JohnH\Desktop\ReactNative Coding\ReactNative\react_native_navigation_01\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:179:41)
at then.result (C:\Users\JohnH\Desktop\ReactNative Coding\ReactNative\react_native_navigation_01\node_modules\#react-native-community\cli-platform-android\build\commands\runAndroid\index.js:133:12)
package.json
{
"name": "react_native_navigation_01",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-community/masked-view": "^0.1.10",
"#react-navigation/native": "^5.9.4",
"#react-navigation/stack": "^5.14.4",
"react": "16.9.0",
"react-native": "0.61.5",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.1.0",
"react-native-safe-area-context": "^3.2.0",
"react-native-screens": "^3.1.1"
},
"devDependencies": {
"#babel/core": "7.13.15",
"#babel/runtime": "7.13.10",
"#react-native-community/eslint-config": "0.0.5",
"babel-jest": "24.9.0",
"eslint": "6.8.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.56.4",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}
I had the same problem today. Since we need to install react-native-reanimated I did check its docs and they aren't supporting react-native < v0.62 and you are using "react-native": "0.61.5" in your package.json.
Try upgrading your react-native dependency. It worked for me. Good luck!
Reference: https://docs.swmansion.com/react-native-reanimated/docs

Metro bundler: Error: EISDIR: illegal operation on a directory, read

When I reload my bundle this exception is uncaught:
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (fs.js:592:3)
at tryReadSync (fs.js:366:20)
at Object.readFileSync (fs.js:403:19)
at UnableToResolveError.buildCodeFrameMessage (/home/brady/obs-websocket-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:347:17)
at new UnableToResolveError (/home/brady/obs-websocket-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:333:35)
at ModuleResolver.resolveDependency (/home/brady/obs-websocket-app/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:211:15)
at DependencyGraph.resolveDependency (/home/brady/obs-websocket-app/node_modules/metro/src/node-haste/DependencyGraph.js:413:43)
at /home/brady/obs-websocket-app/node_modules/metro/src/lib/transformHelpers.js:317:42
at /home/brady/obs-websocket-app/node_modules/metro/src/Server.js:1471:14
at Generator.next (<anonymous>)
My package.json
{
"main": "src/index.js",
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"web": "expo start --web",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"#types/node": "^14.14.35",
"events": "^3.3.0",
"expo": "~40.0.0",
"expo-splash-screen": "~0.8.0",
"expo-updates": "~0.4.0",
"obs-websocket-js": "^4.0.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "~0.64.0",
"react-native-elements": "^3.3.2",
"react-native-gesture-handler": "~1.8.0",
"react-native-reanimated": "~1.13.0",
"react-native-screens": "~2.15.0",
"react-native-unimodules": "~0.12.0",
"react-native-web": "~0.13.12"
},
"devDependencies": {
"#babel/core": "~7.9.0",
"#types/react": "~16.9.35",
"#types/react-dom": "~16.9.8",
"#types/react-native": "~0.63.2",
"babel-preset-expo": "~8.3.0",
"jest-expo": "~40.0.0",
"typescript": "~4.0.0"
},
"jest": {
"preset": "react-native"
},
"private": true
}
Replace this code in `MainApplication.java
#Override
protected String getJSMainModuleName() {
return "src/index"; <---add this
}
For IOS
// packages/myapp/ios/myapp/AppDelegate.m:56
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:#"src/index" fallbackResource:nil];
Apparently there's an issue with moving index.js to src/index.js. I moved it back to the project root and it's working fine now.
Solved by deleting and creating new android emulator...
I got same error, but all going well after I yarn global remove wml
yarn global remove wml
that save my life
if you have never install wml, just consider some other related global libs
----update-----
I got the error again even I uninstall wml staff, but I found my issue's root cause was the watchman, after run brew uninstall watchman, all going well
An old instance of the remote debugger running caused this for me. Not sure of the "whys", but if you want to kill the debugger programmatically, add this to the top of your App.tsx or whatever your top-level entry file is:
import { NativeModules } from 'react-native';
NativeModules.DevSettings.setIsDebuggingRemotely(false);
Credit to Christophe Marois over at this answer How to disable Remote JS Debugging in React-Native
If you are using create-react-native-library for native modules and getting this error. Do the following:
cd example
npx react-native start
In rootDir, yarn example run

Need help in compilation of react-native iOS app

I am relatively new to react-native and trying to compile a previously running project but not able to compile
I am facing this error while compiling the code.
** BUILD FAILED **
Installing build/Build/Products/Debug-iphonesimulator/myapp.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist
Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/myapp.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
I have tried all solutions mentioned below
Print: Entry, ":CFBundleIdentifier", Does Not Exist
this is my package.json file
{
"name": "myapp",
"version": "0.1.0",
"private": true,
"devDependencies": {
"babel-plugin-module-resolver": "^3.1.1",
"babel-preset-react-native-stage-0": "^1.0.1",
"babel-root-slash-import": "^1.1.0",
"eslint-import-resolver-babel-module": "^4.0.0",
"eslint-plugin-import": "^2.11.0",
"jest-react-native": "^18.0.0",
"jetifier": "^1.6.3",
"prop-types": "^15.6.1",
"react-native-dotenv": "^0.1.1",
"react-test-renderer": "16.2.0"
},
"scripts": {
"start": "react-native start",
"android": "react-native run-android",
"ios": "react-native run-ios",
"test": "node node_modules/jest/bin/jest.js",
"clean": "react-native-clean-project"
},
"jest": {
"preset": "react-native"
},
"dependencies": {
"moment": "^2.22.0",
"react": "16.2.0",
"react-native": "0.52",
"react-native-clean-project": "^1.0.8",
"react-native-device-info": "^0.21.5",
"react-native-document-picker": "^2.1.0",
"react-native-firebase": "^4.2.0",
"react-native-htmlview": "^0.12.1",
"react-native-image-picker": "^0.26.7",
"react-native-mime-types": "^2.2.1",
"react-native-network-info": "^3.2.2",
"react-native-pdf": "^4.0.0",
"react-native-photo-view": "^1.5.2",
"react-native-push-notification-ce": "^3.1.3",
"react-native-swiper": "^1.5.13",
"react-native-video": "^2.3.1",
"react-native-video-preview":
"git://github.com/chadsmith/react-native-video-preview.git",
"react-native-video-processing": "^1.13.0",
"react-navigation": "^1.5.8",
"rn-fetch-blob": "^0.10.12"
}
}
Try cleaning up the build folder and deleting DerivedData folder which clears the build cache. But the main reason is that you haven't set the bundle ID for the app. Assuming you followed the link and made sure that you have one, then usually the build being cached is the issue.
I think there are 2 possible causes:
1) At some point there is some other error that is blocking the creation of the JS bundle.
Check the entire log of the build attempt carefully.
2) The bundle is generated at the incorrect path or using the incorrect index.js file.
More info here:
https://stackoverflow.com/a/57604941/1979861

Can't find variable: Store

I'm working on an react-native app since 3 months, and we're currently using v0.21.
In an attempt to upgrade the app in order to fix a bug, I:
ran brew update && brew upgrade
Made some change to package.json
ran npm install
ran npm update -g react-native-cli to get the v0.1.10 locally
At this point I tried to run the app, but either in iOS or Android, I've got the same error:
So Logically I got back to origin/master, remove my node_modules folder, and reinstalled the react-native-cli v0.1.7 ... But I've got the same error !!
My package.json looks like that:
{
"name": "XXXXXX",
"version": "0.0.1",
"private": true,
"dependencies": {
"awesome-phonenumber": "^1.0.10",
"buffer": "^3.6.0",
"immutable": "^3.7.6",
"react-native": "^0.21.0",
"react-native-animatable": "^0.5.0",
"react-native-blur": "^0.7.10",
"react-native-button": "^1.3.1",
"react-native-code-push": "^1.5.3-beta",
"react-native-date": "^1.0.3",
"react-native-device-info": "^0.6.0",
"react-native-drawer-layout": "^0.4.0",
"react-native-facebook-ios": "file:lib/react-native-facebook-ios",
"react-native-facebook-login": "^1.0.2",
"react-native-floating-label-text-input": "0.0.8",
"react-native-google-places-autocomplete": "^1.1.6",
"react-native-material-kit": "^0.2.4",
"react-native-modalbox": "^1.3.1",
"react-native-onesignal": "file:lib/react-native-onesignal",
"react-native-parallax": "^0.2.2",
"react-native-parallax-scroll-view": "^0.16.17",
"react-native-router-flux": "^2.2.6",
"react-native-scrollable-tab-view": "^0.3.5",
"react-native-sync-now-android": "file:lib/react-native-sync-now-android",
"react-native-sync-now-ios": "file:lib/react-native-sync-now-ios",
"react-native-timer-ios": "file:lib/react-native-timer-ios",
"react-native-twitter-ios": "file:lib/react-native-twitter-ios",
"react-native-twitter-login": "0.0.2",
"react-native-utils": "^1.0.1",
"react-native-vector-icons": "^1.0.3",
"react-native-webrtc": "^0.1.5",
"react-redux": "^3.1.0",
"redux": "^3.0.2",
"redux-logger": "^2.0.1",
"redux-thunk": "^1.0.0",
"rnpm": "^1.4.1"
},
"scripts": {
"start": "react-native start",
"postinstall": "sh scripts/postinstall.sh"
},
"devDependencies": {
"react-native-cli": "^0.1.7"
}
}
I'm sure the problem is in the version of my tools because everything happened after I updated them and the code is the same
Here's the versions:
Watchman 4.4.0
Flow 0.22.1
react-native-cli 0.1.7
Can someone help me with this ?
Fixed it !
Because I must have upgraded packagers, it did not like the:
export default variable = {};
It prefers:
const variable = {};
export default variable;
Lost 24 hours on this...