I had the the following added to .bash_profile following the ReactNative Documentation:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
Then I moved it to .bashrc.
Then moved it to .zshrc
$ adb devices
List of devices attached
$
Added to .profile
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
Added to .bashrc
if [ -f $HOME/.bashrc ]; then
source $HOME/.bashrc
fi
launch.json:
{
"configurations": [
{
"name": "Debug Android",
"cwd": "${workspaceFolder}",
"type": "reactnative",
"request": "launch",
"platform": "android"
}
]
}
run by: code {app}
Start Debug Android
App launches in emulator with debugger support
React-Native VS Code extension version: 0.14.2
Version: 1.44.1
OS platform and version: macOS 10.14.6
NodeJS version: v12.4.0
React Native version: 0.62.2
Android Studio version: 3.6.0
Output of the Debug Console (View -> Toggle Debug Console):
[Info] Starting Packager
[Info] Packager started.
[Info] Prewarming bundle cache. This may take a while ...
[Info] About to get: http://localhost:8081/index.bundle?platform=android
[Wed Apr 15 2020 22:43:19.886] BUNDLE ./index.js
[Warning] The Bundle Cache was prewarmed.
[Info] Building and running application.
[Error] Error: Error while executing command 'adb devices': Command failed: adb devices
/bin/sh: adb: command not found
Hi @jaylucas and thanks for reaching us. Could you please tell us which shell you are using: bash or zsh?
zsh, that's enough to add React Native configurations to .zshrc file. So it isn't required to modify .bashrc, .bash_profile, .profile files..bash_profile and then add the following to the end of .zshrc file:
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile;
fi
source ~/.bash_profile
source ~/.zshrc
~/.bashrc file.bash_profile:
if [ -f $HOME/.bashrc ]; then
source $HOME/.bashrc
fi
source ~/.bash_profilesource ~/.bashrcPlease let us know about your results.
Thanks for the quick response!
Weird I thought I tried that, now I am getting:
[Error] Error: Error while executing command '/Users/XXXX/Desktop/AwesomeProject/node_modules/.bin/react-native run-android --no-packager':
Error while executing command '/Users/XXXX/Desktop/AwesomeProject/node_modules/.bin/react-native run-android --no-packager' (error code 101)
Looking at: https://github.com/microsoft/vscode-react-native/issues/1169
Adding to .bashrc:
export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
didn't work.
Hi @jaylucas . Please check outputs from React Native: Run android output channel. You can find it this way: View -> Toggle Output -> Select React Native: Run android in ListBox.
Could you please look at the outputs in this channel and send them to us? They might contain Android build error.
Sorry is this what you needed?
* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /Users/XXXX/Library/Android/sdk
* 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 3s
error Failed to install the app. Please accept all necessary Android SDK licenses using Android SDK Manager: "$ANDROID_HOME/tools/bin/sdkmanager --licenses". Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;28.0.3 Android SDK Build-Tools 28.0.3
platforms;android-28 Android SDK Platform 28
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /Users/XXXX/Library/Android/sdk
* 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 3s
at makeError (/Users/XXXX/Desktop/AwesomeProject/node_modules/execa/index.js:174:9)
at /Users/XXXX/Desktop/AwesomeProject/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:89:5)
@jaylucas Yes, thank you. It seems that the user agreement in the installed Android SDK version is not accepted yet so it cannot work without it. You need to accept it, you can do this using the following command and accepting all needed licenses:
sdkmanager --licenses
If for some reason sdkmanager binary wasn't found automatically you can use the following commands:
cd ~/Library/Android/sdk/tools/bin/
./sdkmanager --licenses
Please let us know if this helped or if you faced any other issue with the extension.
Omg, yeah it helps to read. Thanks. Now I am getting:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:installDebug'.
> com.android.builder.testing.api.DeviceException: No connected devices!
* 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 5s
at makeError (/Users/XXX/Desktop/AwesomeProject/node_modules/execa/index.js:174:9)
at /Users/XXX/Desktop/AwesomeProject/node_modules/execa/index.js:278:16
at processTicksAndRejections (internal/process/task_queues.js:89:5)
$emulator -avd -list-avds
Nexus_5X_API_24
Nexus_5X_API_26_Kit-kat
Nexus_6_API_26
Pixel_2_API_24
Pixel_API_26
$emulator -avd Nexus_6_API_26
Hax is enabled
Hax ram_size 0x60000000
Failed to create vm ffffffff
Failed to create HAX VM
No accelerator found.
failed to initialize HAX: Invalid argument
I know this problem seems to go beyond vscode but any ideas?
From the error it looks like you have problems with hardware acceleration VMs.
https://developer.android.com/studio/run/emulator-acceleration#vm-mac has information on how to enable that in case you haven't already.
@jaylucas Have you tried the recommendation above?
@jaylucas I am closing this issue due to inactivity. Feel free to reopen if needed.
Sorry, I thought I commented.
For those struggling with the same issue: I deleted all the Android images and reinstalled newer versions which solved the problem. Thanks!!