Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native adb reverse ENOENT

I am trying to get React-Native to work with Android V4.2.2 (Genymotion) but I am unable to test the app on the Emulator. When I ran react-native run-android, I get this error Could not run adb reverse: spawnSync

Here is a log

JS server already running.
Running ~/Library/Android/sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT
Building and installing the app on the device (cd android && ./gradlew installDebug...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '~/Library/Android/sdk' does not exist.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 3.785 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

NOTE: In the log it saids SDK directory does not exist, I have double check that I do have the SDK installed in that directory.

I found my android emulator when executing adb devices

List of devices attached
192.168.56.101:5555 device

I have tried the following steps from Stack Overflow post, but still no luck https://stackoverflow.com/a/38536290/4540216

like image 444
XPLOT1ON Avatar asked Aug 08 '16 18:08

XPLOT1ON


4 Answers

Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well. More details on zsh from Apple

So on your Mac:

1 - Open your .zshrc file:

open ~/.zshrc

2 - if .zshrc file doesn't exist, you need to create one & open again(Step 1)

touch ~/.zshrc

3 - Add this to your .zshrc file(Add JAVA_HOME to use Android Studio Embedded JDK)

export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
export ANDROID_HOME=/Users/<your_computer_name_here>/Library/Android/sdk
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH

4 - Save and close

5 - Compile your changes

source ~/.zshrc

& make sure to restart your terminal.

like image 21
AbhinayMe Avatar answered Nov 11 '22 09:11

AbhinayMe


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

Follow this React-native android-setup documentation

ex:

export ANDROID_HOME=~/Library/Android/sdk

Windows:

set ANDROID_HOME=c:/Users/whoever/AppData/Local/Android/Sdk

macOS Mojave and earlier or bash users:

1 - Open your bash profile:

open .bash_profile

Add this to your bash_profile:

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

Save and close

Compile your changes

source ~/.bash_profile

For macOS Catalina and zsh users:

Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.

On your Mac:

Open your .zshrc file:

open ~/.zshrc

If .zshrc file not exist, you need to create one using touch & open.

touch ~/.zshrc

Add this to your .zshrc file

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

Save and close

Compile your changes

source ~/.zshrc

Edit: Updated answer for macOS Catalina and zsh users.

like image 97
SureshCS50 Avatar answered Nov 11 '22 08:11

SureshCS50


I also got the same issue. And I updated my ANDROID_HOME env variable again in same cmd and it was worked fine.

> export ANDROID_HOME=~/Android/Sdk 
> export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

good luck

like image 19
Dinithe Pieris Avatar answered Nov 11 '22 10:11

Dinithe Pieris


This answer is for MacOs Catalina or above user or zsh users as your Mac now uses zsh as the default login shell and interactive shell.

This is related to path issues.

If you follow along with the docs of React Native Setting up the development environment guide. Then do the following.

  1. Open ~/.zshrc using editor. In my case I use vim
vim ~/.zshrc
  1. Add the following line for the path.
export ANDROID_HOME="/Users/<yourcomputername>/Library/Android/sdk"
export PATH=$ANDROID_HOME/emulator:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH

Make sure to add the above line correctly else it will give you a weird error.

  1. Save the changes and close the editor.

  2. Finally, now compile your changes

source ~/.zshrc

I get this working in my case. I hope this helps you.

like image 13
Pratap Sharma Avatar answered Nov 11 '22 08:11

Pratap Sharma