Created
October 12, 2017 18:20
-
-
Save wbroek/a2caf1ace90eac0c5e25497548f41a6e to your computer and use it in GitHub Desktop.
Visual Studio Code task to start the Android Emulator (for React Native development)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "2.0.0", | |
"reveal": "silent", | |
"tasks": [{ | |
"taskName": "Start Android Emulator", | |
"type": "shell", | |
"isBackground": true, | |
"command": "~/Library/Android/sdk/tools/emulator", | |
"args": [ | |
"-avd", | |
"[AVD_NAME]", | |
">", | |
"/dev/null", | |
"2>&1", | |
"&" | |
], | |
"problemMatcher": [], | |
"presentation": { | |
"reveal": "never" | |
} | |
}] | |
} |
I am trying to avoid this error by removing "isBackground": true
from the task. Then using a shell script which finishes after loading the emulator, but although detaching the process from the terminal using &
, nohup
or disown
, the emulator closes when vscode finishes the prelaunch task.
Running the script in a terminal works as expected, with ctrl + c
oder closing the terminal the emulator stays open.
Here is my script:
#!/usr/bin/env bash
# start emulator as headless process
# nohup emulator @Nexus_5X_API_28 -no-boot-anim & disown
# wait for emulator to be started
adb wait-for-device & disown
# wait for android to be booted
while [ "`adb shell getprop sys.boot_completed | tr -d '\r' `" != "1" ] ; do sleep 1; done
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @wbroek,
thanks for sharing this, I was searching for something like this.
But there is a problem which is discussed here link.
After 10 seconds I get the warning "The specified task cannot be tracked".
Seems like vscode is waiting for an answer to check if the preLaunchTask was startet successfully.
I could choose "Debug anyway" but doing this every build is annoying!
Did you faced this problem? Regards