Expo / React Native Error : spawnSync lsof ENOENT - android

I am working currently on an expo app and I recently came up with this issue : when I run npx expo start and then I press a to open the app on an Android Emulator I get this error :
› Opening on Android...
› Opening http://127.0.0.1:19000/_expo/loading?platform=android on Pixel_4_API_33
Couldn't start project on Android: spawnSync lsof ENOENT
I tried different emulators but I still get the error everytime...

The error came from the fact that I did not have an ANDROID_HOME variable inside my PATH. I just followed the instructions here and problem solved !

Ensure that lsof command is in the system's PATH.
Also you can try the command npx expo start --clear

Related

How to fix "Error spawn Unknown system error -8" in react native

I have that weird error when running "npx react-native run-android" that is only occuring in a specific react native project only on my Macbook with android simulator. Other RN apps are running fine on my mac with android.
On a windows pc this specific RN app is also working fine.
Error: spawn Unknown system error -8
at ChildProcess.spawn (node:internal/child_process:413:11)
at Object.spawn (node:child_process:743:9)
at module.exports (/Users/hannes/Projects/test2/mapp/native-frame/node_modules/#react-native-community/cli-platform-android/node_modules/execa/index.js:205:26)
I tried the following things:
deleting package-lock.json
rm -r node_modules + gradlew clean (in android folder)
creating a new virtual device in android studio with API level according to build.gradle
upgrading node to 18.8.0
upgrading npm to 8.18.0
npm cache clean –force
Somebody any ideas?
After using "run-ios" in the meantime I had to face the problem again and found a solution.
npx react-native run-android
this line is using the port 8081 and my macbook did sometimes use this port for another service
lsof -i tcp:8081
this command showed the process that was running
COMMAND PID FD DEVICE SIZE/OFF NODE NAME
node 44492 24u 0t0 TCP *:sunproxyadmin (LISTEN)
I terminated this process but still got the error message.
So I called the gradle command for building and installing the app myself.
cd android && ./gradlew app:installDebug -PreactNativeDevServerPort=8081
This worked, the app got build and installed on my android device but I got multiple error messages in the android studio run console starting with:
Could not find generated setter for class
this error was also addressed on GitHub and Stackoverflow
So building and installing the app in production mode solved the problem for me.
./gradlew app:installRelease

Not able to run android emulator (android-studio) with react-native

I am just starting to create a new react-native project and I followed the steps exactly as mentioned in setting-up environment for react-native.
My development OS: Mac; My target OS: Android
I created a local.properties file in my project/android directory which mentions sdk path. I have the android emulator up and running, then I do yarn react-native start, and in another terminal window, yarn react-native run:android but I get the following error:
BUILD SUCCESSFUL in 28s
27 actionable tasks: 27 executed
info Connecting to the development server...
warn Failed to connect to development server using "adb reverse": spawnSync adb ENOENT
info Starting the app...
error Failed to start the app. Run CLI with --verbose flag for more details.
Error: spawnSync adb ENOENT
at Object.spawnSync (internal/child_process.js:1066:20)
error Command failed with exit code 1.
yarn react-native run:ios command runs perfectly alright.
Could anyone help with this please? I have tried the various different suggestions mentioned in this stackoverflow question but no luck.

How to solve Could not run adb reverse: spawnSync C\:\\Users\\Name\\AppData\\Local\\Android\\Sdk/platform-tools/adb ENOENT in React native project?

In my react-native project directory, whenever I run the following command to run the project-
react-native run-android
The metro bundle starts and port 8081 is open but it shows the following error-
Could not run adb reverse: spawnSync
C:\Users\UserName\AppData\Local\Android\Sdk/platform-tools/adb
ENOENT
So, the app is not running in my adb device. I need a solution to solve it.
Looks like the path is using a mixture of backslashes and forward slashes:
C:\Users\UserName\AppData\Local\Android\Sdk/platform-tools/adb
I would use that as the starting point for your investigation. Does RN know you are using Windows? Are you using a suitable CLI such as the one provided by Git SCM? I suspect you will have issues if you are running directly from cmd.

React Native response error 500

enter image description here]1
I am doing following step to start react application
react-native init reactTutorialApp
react-native run-android
by followed these steps and it is installing on Device successfully. but i am getting a following error.
The development server return response error code:500
PFA
I think you forgot to run one command, the one to start the development server.
Try:
react-native init reactTutorialApp
run the following command in the project root folder, but in another tab (this process need to be running when you're developing:
react-native start
And now you can run: react-native run-android
Tell me if it solve your problem.

vscode use react native tools run react native project , but adb devices /bin/sh: adb: command not found

I use vscode extension run react native project
but console
[Error : 0101] Failed to run the application in Android: Error while executing command 'adb devices': Command failed: adb devices /bin/sh: adb: command not found
I use terminal use react-native run-android , it can run , i write the config in .bash_profile and .zshrc file , how to solve it ?
I always meet with situation but after research I found a solution as below
But make sure your have to restart your MAC OS

Categories

Resources