beansoft / react-native-console

đŸ§© an IDEA/WebStorm/Android Studio Plugin for One-Click run React Native commands in embed terminal
BSD 3-Clause "New" or "Revised" License
185 stars 28 forks source link

/bin/sh: 1: adb: not found #45

Closed mbenoukaiss closed 4 years ago

mbenoukaiss commented 4 years ago

Hello, I have a problem where running RN apps from terminal works fine but fails when using RN Console.

The adb command is in path and works when ran from terminal, the same for react-native run-androidwhich works fine and launches the app on the emulator when I run it in a terminal.

image

However when I try to do run-android using React Native Console, I get the following output :

/usr/bin/yarn react-native run-android
yarn run v1.21.1
$ /mnt/hdd/projects/react/todo/node_modules/.bin/react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 977 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Launching emulator...
info Installing the app...
/bin/sh: 1: adb: not found
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.

The Run Android Emulator also fails telling me no android AVD was found but when I try to run emulator -list-avds, it returns the name of one emulator as shown in the screenshot above.

My path exports (in .zshrc) :

export ANDROID_SDK_ROOT=/opt/android-sdk
export ANDROID_HOME=$ANDROID_SDK_ROOT
export ANDROID_SDK_HOME=$ANDROID_SDK_ROOT/avd
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin

I'm using Debian and ZSH, and the IDE is Intellij 2020.1. I tried specifying the PATH exports in both my .bashrc and .zshrc and restart intellij but it didn't change anything.

Thank you for your help.

stephanoparaskeva commented 4 years ago

Having the same issue

beansoft commented 4 years ago

It's a known bug in IDEA's path parsing, see https://github.com/beansoftapp/react-native-console/issues/17.

You can try a workaround: sudo ln -s ~/Android/Sdk/platform-tools/adb /usr/bin/adb

. Or on your machine it should be: sudo ln -s /opt/android-sdk/platform-tools/adb /usr/bin/adb

mbenoukaiss commented 4 years ago

Thank you, I executed the command you gave and now I get the following output :

cd "/mnt/hdd/projects/react/todo"
/usr/bin/yarn react-native run-android
yarn run v1.21.1
$ /mnt/hdd/projects/react/todo/node_modules/.bin/react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 977 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
* daemon not running; starting now at tcp:5037
* daemon started successfully
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found as an output of `emulator -list-avds`.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings

FAILURE: Build failed with an exception.

* What went wrong:
Task 'installDebug' not found in project ':app'.

* Try:
Run gradlew tasks to get a list of available tasks. 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

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* What went wrong:
Task 'installDebug' not found in project ':app'.

* Try:
Run gradlew tasks to get a list of available tasks. 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 makeError (/mnt/hdd/projects/react/todo/node_modules/execa/index.js:174:9)
    at /mnt/hdd/projects/react/todo/node_modules/execa/index.js:278:16
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async runOnAllDevices (/mnt/hdd/projects/react/todo/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:5)
    at async Command.handleAction (/mnt/hdd/projects/react/todo/node_modules/react-native/node_modules/@react-native-community/cli/build/index.js:186:9)
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.

(an emulator was running and react-native start was also running)

However everything still works if I do it from terminal, and the installDebug task exists:

 react/todo/android ./gradlew tasks | grep installDebug
installDebug - Installs the Debug build.
installDebugAndroidTest - Installs the android (on device) tests for the Debug build.
uninstallDebug - Uninstalls the Debug build.
uninstallDebugAndroidTest - Uninstalls the android (on device) tests for the Debug build.
beansoft commented 4 years ago

@mbenoukaiss this should be an android env issue, not the plugin's fault, you can verify it by execute the command cd "/mnt/hdd/projects/react/todo" /usr/bin/yarn react-native run-android in a terminal. Please add a android/local.properties file and point to your android sdk dir.

sdk.dir=/Users/xxx/Java/android-sdk-home

mbenoukaiss commented 4 years ago

Indeed, that fixed the issue, thank you!