diff --git a/src/chrome/DevicesButton.js b/src/chrome/DevicesButton.js index 8ee411035b8..79e3c9bfbeb 100644 --- a/src/chrome/DevicesButton.js +++ b/src/chrome/DevicesButton.js @@ -21,14 +21,12 @@ type Props = { class DevicesButton extends Component { launchEmulator = (name: string) => { - const child = spawn( - `${process.env.ANDROID_HOME || ''}/tools/emulator`, - [`@${name}`], - { - detached: true, - stdio: 'ignore', - }, - ); + const child = spawn('emulator', [`@${name}`], { + detached: true, + }); + child.stderr.on('data', data => { + console.error(`Android emulator error: ${data}`); + }); child.on('error', console.error); this.props.preferDevice(name); }; diff --git a/src/dispatcher/androidDevice.js b/src/dispatcher/androidDevice.js index 199bd5af0f1..96cd22d06fa 100644 --- a/src/dispatcher/androidDevice.js +++ b/src/dispatcher/androidDevice.js @@ -59,7 +59,7 @@ export default (store: Store, logger: Logger) => { const watchAndroidDevices = () => { // get emulators child_process.exec( - '$ANDROID_HOME/tools/emulator -list-avds', + 'emulator -list-avds', (error: ?Error, data: ?string) => { if (error != null || data == null) { console.error(error || 'Failed to list AVDs'); diff --git a/static/index.js b/static/index.js index 24bac57781f..fbf69943133 100644 --- a/static/index.js +++ b/static/index.js @@ -23,6 +23,12 @@ if (!process.env.ANDROID_HOME) { process.env.ANDROID_HOME = '/opt/android_sdk'; } +// emulator/emulator is more reliable than tools/emulator, so prefer it if +// it exists +process.env.PATH = `${process.env.ANDROID_HOME}/emulator:${ + process.env.ANDROID_HOME +}/tools:${process.env.PATH}`; + if (process.platform === 'darwin') { // If we are running on macOS and the app is called Flipper, we add a comment // with the old name, to make it findable via Spotlight using its old name.