Skip to content

Commit

Permalink
Fix emulator launching bug
Browse files Browse the repository at this point in the history
Summary:
I was getting the following error when trying to launch an emulator:
`PANIC: Missing emulator engine program for 'x86' CPU.`

It seems like emulator/emulator is more reliable than tools/emulator: https://stackoverflow.com/questions/26483370/android-emulator-error-message-panic-missing-emulator-engine-program-for-x86

So put them both on the path in that order.

Reviewed By: passy

Differential Revision: D13040325

fbshipit-source-id: 11e8b24b2a99e02955128d5fb7c17764b98388fa
  • Loading branch information
jknoxville authored and facebook-github-bot committed Nov 13, 2018
1 parent 5723513 commit d9a9439
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/chrome/DevicesButton.js
Expand Up @@ -21,14 +21,12 @@ type Props = {

class DevicesButton extends Component<Props> {
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);
};
Expand Down
2 changes: 1 addition & 1 deletion src/dispatcher/androidDevice.js
Expand Up @@ -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');
Expand Down
6 changes: 6 additions & 0 deletions static/index.js
Expand Up @@ -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.
Expand Down

0 comments on commit d9a9439

Please sign in to comment.