-
-
Save wbroek/a2caf1ace90eac0c5e25497548f41a6e to your computer and use it in GitHub Desktop.
{ | |
"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" | |
} | |
}] | |
} |
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
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
Create this task as a preLaunchTask for the launch.json so the Android emulator is started before react native is started