1
votes

I am getting the below error while trying to run the following command : sudo react-native run-android

I have tried all the approches from here but to no avail: React Native adb reverse ENOENT

Moreover the problem did not occur when I run the same command without using sudo ,I further tried updating adb and copying the root Android folder to $USERS/Android but none of the approaches worked . Would be very great if I could recieve some help in this

debug Running command "$HOME/Android/Sdk/platform-tools/adb -s f4de483e reverse tcp:8081 tcp:8081"
warn Failed to connect to development server using "adb reverse": spawnSync $HOME/Android/Sdk/platform-tools/adb ENOENT
info Starting the app on "f4de483e"...
debug Running command "$HOME/Android/Sdk/platform-tools/adb -s f4de483e shell am start -n com.grej_frontend/com.grej_frontend.MainActivity"
error Failed to start the app.
Error: spawnSync $HOME/Android/Sdk/platform-tools/adb ENOENT
    at Object.spawnSync (internal/child_process.js:1002:20)```
3
Try out the answers here: stackoverflow.com/questions/38835931/…RowanX

3 Answers

2
votes

I have the same problem and I noticed that my ~/.bashrc file had a different path like the following

export PATH=$PATH:/usr/local/opt/android-sdk/tools:/usr/local/opt/android-sdk/platform-tools

Then I removed it and I kept the following and it was fixed:

export ANDROID_HOME=$HOME/Android/Sdk
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools

export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

0
votes

The error was that there was a seperate .bashrc file for sudo user which I was not updating. Updating that file with proper paths fixed my error.

0
votes

I got the same issue. I updated my ANDROID_HOME env variable again it worked for me.

Paste this in your terminal

export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH

Follow this https://reactnative.dev/docs/getting-started#3-configure-the-android_home-environment-variable

https://stackoverflow.com/a/38847005/7854303