Skip to content

run-android doesn't start app on device when ANDROID_HOME not set #375

@nnnnnoel

Description

@nnnnnoel

Environment

React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Pentium(R) CPU G4600 @ 3.60GHz
Memory: 2.37 GB / 7.89 GB
Binaries:
Yarn: 1.15.2 - C:\Users\Shinpei\AppData\Roaming\npm\yarn.CMD
npm: 6.7.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.4.0.0 AI-183.5429.30.34.5452501

Description

it doesnt start app when we dont have ANDROID_HOME in $PATH and finished react-native run-android.

Reproducible Demo

'use strict';

Object.defineProperty(exports, '__esModule', {
  value: true,
});
// eslint-disable-next-line no-void
exports.default = void 0;

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
@@ -6,11 +14,34 @@
 *
 * @flow
 */
function getOS() {
  var platform = window.navigator.platform,
    macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
    windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
    os = null;

  if (macosPlatforms.indexOf(platform) !== -1) {
    os = 'Mac OS';
  } else if (windowsPlatforms.indexOf(platform) !== -1) {
    os = 'Windows';
  } else if (!os && /Linux/.test(platform)) {
    os = 'Linux';
  }

  return os;
}

function getAdbPath() {
  return process.env.ANDROID_HOME
    ? `${process.env.ANDROID_HOME}/platform-tools/adb`
    : getOS() === 'Windows'
    ? `C:/Users/${
        require('os').userInfo().username
      }/AppData/Local/Android/Sdk/platform-tools/adb`
    : `/Users/${
        require('os').userInfo().username
      }/Library/Android/sdk/platform-tools/adb`;
}

var _default = getAdbPath;
exports.default = _default;

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions