ionic-team / native-run

Utility for running native binaries on iOS and Android devices and simulators/emulators
MIT License
127 stars 21 forks source link

`--list` ECONNREFUSED 127.0.0.1:27015 #35

Open colinl-intelliacc opened 5 years ago

colinl-intelliacc commented 5 years ago

Description

When running native-run --list, an unhandled error is thrown. It seems a connection attempt is being made to 127.0.0.1:27015, but the connection is failing. This results in devices not being found, even though adb returns the devices correctly.

Output

native-run --list --verbose
2019-06-05T08:12:33.758Z client:usbmuxd connectUsbmuxdSocket
2019-06-05T08:12:33.771Z client:usbmuxd getDevices
2019-06-05T08:12:33.772Z protocol:usbmux socket write: {"messageType":"ListDevices"}
2019-06-05T08:12:33.778Z native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME
2019-06-05T08:12:33.778Z native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_SDK_ROOT
2019-06-05T08:12:33.780Z native-run:ios:list There was an error getting the iOS simulator list: Error: spawnSync xcodebuild ENOENT
    at Object.spawnSync (internal/child_process.js:1041:20)
    at Object.spawnSync (child_process.js:602:24)
    at Object.getXcodeVersionInfo (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\ios\utils\xcode.js:8:46)
    at Object.getSimulators (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\ios\utils\simulator.js:11:36)
    at Object.list (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\ios\list.js:19:43)
    at C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\list.js:5:85
    at async Promise.all (index 0)
    at async Object.run (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\list.js:4:40)
    at async Object.run (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\index.js:28:13) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawnSync xcodebuild',
  path: 'xcodebuild',
  spawnargs: [ '-version' ]
}
2019-06-05T08:12:33.782Z native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_SDK_ROOT at C:\Users\User\AppData\Local\Android\Sdk
2019-06-05T08:12:33.782Z native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME
2019-06-05T08:12:33.782Z native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at C:\Users\User\.android
2019-06-05T08:12:33.782Z native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME
2019-06-05T08:12:33.782Z native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at C:\Users\User\.android\avd
2019-06-05T08:12:33.783Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platform-tools\package.xml
2019-06-05T08:12:33.790Z native-run:android:utils:avd:getAVDINIs Discovered AVD ini files: []
2019-06-05T08:12:33.790Z native-run:android:utils:sdk:findAllSDKPackages Walking C:\Users\User\AppData\Local\Android\Sdk to discover SDK packages
2019-06-05T08:12:33.801Z native-run:android:utils:adb:getDevices Invoking adb: 'C:\\Users\\User\\AppData\\Local\\Android\\Sdk\\platform-tools/adb' [ 'devices', '-l' ]
2019-06-05T08:12:33.830Z native-run:android:utils:adb:parseAdbDevices Parsing adb devices from output lines: [
  'List of devices attached',
  'X511XXCH88151959       device product:CUBOT_KING_KONG ' +
    'model:CUBOT_KING_KONG device:CUBOT_KING_KONG ' +
    'transport_id:1',
  '',
  ''
]
2019-06-05T08:12:33.831Z native-run:android:utils:adb:getDeviceProperties Invoking adb: 'C:\\Users\\User\\AppData\\Local\\Android\\Sdk\\platform-tools/adb' [ '-s', 'X511XXCH88151959', 'shell', 'getprop' ]
2019-06-05T08:12:33.961Z native-run:android:utils:adb:getDevices Found adb devices: [
  {
    serial: 'X511XXCH88151959',
    state: 'device',
    type: 'emulator',
    connection: null,
    properties: {
      product: 'CUBOT_KING_KONG',
      model: 'CUBOT_KING_KONG',
      device: 'CUBOT_KING_KONG',
      transport_id: '1'
    },
    manufacturer: 'CUBOT',
    model: 'CUBOT KING KONG',
    product: 'CUBOT_KING_KONG',
    sdkVersion: '24'
  }
]
2019-06-05T08:12:35.094Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\emulator\package.xml
2019-06-05T08:12:35.094Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\tools\package.xml
2019-06-05T08:12:35.095Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\build-tools\28.0.3\package.xml
2019-06-05T08:12:35.095Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\patcher\v4\package.xml
2019-06-05T08:12:35.095Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platforms\android-24\package.xml
2019-06-05T08:12:35.095Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platforms\android-27\package.xml
2019-06-05T08:12:35.095Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platforms\android-28\package.xml
2019-06-05T08:12:35.095Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\sources\android-28\package.xml
2019-06-05T08:12:35.119Z native-run:android:utils:sdk:api:getAPILevels Discovered installed API Levels: [
  {
    apiLevel: '28',
    packages: [ 'platforms;android-28', 'sources;android-28' ]
  },
  { apiLevel: '27', packages: [ 'platforms;android-27' ] },
  { apiLevel: '24', packages: [ 'platforms;android-24' ] }
]
2019-06-05T08:12:35.119Z native-run:android:utils:avd:getDefaultAVDSchematic Issue with API 28: Unsatisfied packages within API 28: system-images;android-28;google_apis_playstore;x86
2019-06-05T08:12:35.120Z native-run:android:utils:avd:getDefaultAVDSchematic Issue with API 27: Unsatisfied packages within API 27: system-images;android-27;google_apis_playstore;x86
2019-06-05T08:12:35.120Z native-run:android:utils:avd:getDefaultAVDSchematic Issue with API 24: Unsatisfied packages within API 24: system-images;android-24;google_apis_playstore;x86
2019-06-05T08:12:35.120Z native-run:android:utils:list:getVirtualTargets Error getting virtual targets: AVDException [Error]: No suitable API installation found.
    at getDefaultAVDSchematic (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\android\utils\avd.js:92:11) {
  code: 'ERR_UNSUITABLE_API_INSTALLATION',
  exitCode: 1,
  data: undefined
}
events.js:177
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:27015
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1054:14)
Emitted 'error' event at:
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:9) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 27015
}
imhoffd commented 5 years ago

Looks like you're on Windows and it's trying to get iOS devices. We'll improve this message soon. For now, you can use native-run android --list to only list Android devices.

colinl-intelliacc commented 5 years ago

The [ios|android] argument option slipped past me. native-run android --list does indeed get rid of the error. Unfortunately the device list does not return connected devices that have been discovered by adb. Could this perhaps be because no virtual devices are present?

Output

native-run android --list --verbose
2019-06-06T06:48:47.107Z native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME
2019-06-06T06:48:47.108Z native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_SDK_ROOT
2019-06-06T06:48:47.110Z native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_SDK_ROOT at C:\Users\User\AppData\Local\Android\Sdk
2019-06-06T06:48:47.111Z native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME
2019-06-06T06:48:47.111Z native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at C:\Users\User\.android
2019-06-06T06:48:47.111Z native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME
2019-06-06T06:48:47.111Z native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at C:\Users\User\.android\avd
2019-06-06T06:48:47.112Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platform-tools\package.xml
2019-06-06T06:48:47.124Z native-run:android:utils:avd:getAVDINIs Discovered AVD ini files: []
2019-06-06T06:48:47.124Z native-run:android:utils:sdk:findAllSDKPackages Walking C:\Users\User\AppData\Local\Android\Sdk to discover SDK packages
2019-06-06T06:48:47.139Z native-run:android:utils:adb:getDevices Invoking adb: 'C:\\Users\\User\\AppData\\Local\\Android\\Sdk\\platform-tools/adb' [ 'devices', '-l' ]
2019-06-06T06:48:47.164Z native-run:android:utils:adb:parseAdbDevices Parsing adb devices from output lines: [ 'List of devices attached',
  'X511XXCH88151959       device product:CUBOT_KING_KONG model:CUBOT_KING_KONG device:CUBOT_KING_KONG transport_id:2',
  '',
  '' ]
2019-06-06T06:48:47.165Z native-run:android:utils:adb:getDeviceProperties Invoking adb: 'C:\\Users\\User\\AppData\\Local\\Android\\Sdk\\platform-tools/adb' [ '-s', 'X511XXCH88151959', 'shell', 'getprop' ]
2019-06-06T06:48:47.275Z native-run:android:utils:adb:getDevices Found adb devices: [ { serial: 'X511XXCH88151959',
    state: 'device',
    type: 'emulator',
    connection: null,
    properties:
     { product: 'CUBOT_KING_KONG',
       model: 'CUBOT_KING_KONG',
       device: 'CUBOT_KING_KONG',
       transport_id: '2' },
    manufacturer: 'CUBOT',
    model: 'CUBOT KING KONG',
    product: 'CUBOT_KING_KONG',
    sdkVersion: '24' } ]
2019-06-06T06:48:48.333Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\emulator\package.xml
2019-06-06T06:48:48.333Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\tools\package.xml
2019-06-06T06:48:48.333Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\build-tools\28.0.3\package.xml
2019-06-06T06:48:48.333Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\patcher\v4\package.xml
2019-06-06T06:48:48.333Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platforms\android-24\package.xml
2019-06-06T06:48:48.334Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platforms\android-27\package.xml
2019-06-06T06:48:48.334Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platforms\android-28\package.xml
2019-06-06T06:48:48.334Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\sources\android-28\package.xml
2019-06-06T06:48:48.363Z native-run:android:utils:sdk:api:getAPILevels Discovered installed API Levels: [ { apiLevel: '28',
    packages: [ 'platforms;android-28', 'sources;android-28' ] },
  { apiLevel: '27', packages: [ 'platforms;android-27' ] },
  { apiLevel: '24', packages: [ 'platforms;android-24' ] } ]
2019-06-06T06:48:48.364Z native-run:android:utils:avd:getDefaultAVDSchematic Issue with API 28: Unsatisfied packages within API 28: system-images;android-28;google_apis_playstore;x86
2019-06-06T06:48:48.365Z native-run:android:utils:avd:getDefaultAVDSchematic Issue with API 27: Unsatisfied packages within API 27: system-images;android-27;google_apis_playstore;x86
2019-06-06T06:48:48.365Z native-run:android:utils:avd:getDefaultAVDSchematic Issue with API 24: Unsatisfied packages within API 24: system-images;android-24;google_apis_playstore;x86
2019-06-06T06:48:48.365Z native-run:android:utils:list:getVirtualTargets Error getting virtual targets: { Error: No suitable API installation found.
    at getDefaultAVDSchematic (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\android\utils\avd.js:92:11)
  code: 'ERR_UNSUITABLE_API_INSTALLATION',
  exitCode: 1,
  data: undefined }
Connected Devices:

  No connected devices found

Virtual Devices:

  No virtual devices found
imhoffd commented 5 years ago

Interesting... is the CUBOT_KING_KONG a hardware device? If so, how is it connected?

colinl-intelliacc commented 5 years ago

Yes, it's a hardware device. It's connected via USB to the computer we're seeing output on. I've attached adb shell getprop output in an attempt to provide more information about the device.

cubot_king_kong_adb_shell_getprop.txt

I believe issue #36 is what we're seeing here.

imhoffd commented 5 years ago

@colinl-intelliacc native-run 0.2.7 was just released to fix up this issue. I am marking this as fixed! Let me know if you have any more issues and thanks for your patience!

colinl-intelliacc commented 5 years ago

Thanks! After testing I can confirm that the Android device is getting listed when native-run android --list is called. Unfortunately when calling native-run --list without a platform being specified on a Windows machine, the iOS device retrieval still throws and unhandled error, which results in present Android devices not being listed.

Printing a message that iOS devices are not retrievable on the running operating system would be good. Preventing the execution from halting on the error would be great. All-in-all it's not preventing productivity at the moment, it might just result in some momentary head scratching before --help is called.

Output

native-run --list --verbose
2019-06-27T05:42:59.686Z client:usbmuxd connectUsbmuxdSocket
2019-06-27T05:42:59.703Z client:usbmuxd getDevices
2019-06-27T05:42:59.704Z protocol:usbmux socket write: {"messageType":"ListDevices"}
2019-06-27T05:42:59.714Z native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME
2019-06-27T05:42:59.715Z native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_SDK_ROOT
Error with iOS virtual targets: Error: spawnSync xcodebuild ENOENT
    at Object.spawnSync (internal/child_process.js:1002:20)
    at Object.spawnSync (child_process.js:614:24)
    at Object.getXcodeVersionInfo (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\ios\utils\xcode.js:8:46)
    at Object.getSimulators (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\ios\utils\simulator.js:14:36)
    at Promise.all (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\ios\list.js:25:54)
    at Object.list (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\ios\list.js:32:11)
    at Promise.all (C:\Users\User\AppData\Roaming\npm\node_modules\native-run\dist\list.js:13:34)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
    at startup (internal/bootstrap/node.js:283:19)
2019-06-27T05:42:59.718Z native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_SDK_ROOT at C:\Users\User\AppData\Local\Android\Sdk
2019-06-27T05:42:59.718Z native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME
2019-06-27T05:42:59.718Z native-run:android:utils:sdk:resolveEmulatorHome Looking at $HOME/.android
2019-06-27T05:42:59.718Z native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at C:\Users\User\.android
2019-06-27T05:42:59.718Z native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME
2019-06-27T05:42:59.718Z native-run:android:utils:sdk:resolveAVDHome Looking at $HOME/.android/avd
2019-06-27T05:42:59.718Z native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at C:\Users\User\.android\avd
2019-06-27T05:42:59.719Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platform-tools\package.xml
2019-06-27T05:42:59.729Z native-run:android:utils:avd:getAVDINIs Discovered AVD ini files: []
2019-06-27T05:42:59.729Z native-run:android:utils:sdk:findAllSDKPackages Walking C:\Users\User\AppData\Local\Android\Sdk to discover SDK packages
2019-06-27T05:42:59.743Z native-run:android:utils:adb:getDevices Invoking adb: 'C:\\Users\\User\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb' [ 'devices', '-l' ]
2019-06-27T05:42:59.767Z native-run:android:utils:adb:parseAdbDevices Parsing adb devices from output lines: [ 'List of devices attached',
  'X511XXCH88151959       device product:CUBOT_KING_KONG model:CUBOT_KING_KONG device:CUBOT_KING_KONG transport_id:2',
  '',
  '' ]
2019-06-27T05:42:59.768Z native-run:android:utils:adb:getDeviceProperties Invoking adb: 'C:\\Users\\User\\AppData\\Local\\Android\\Sdk\\platform-tools\\adb' [ '-s', 'X511XXCH88151959', 'shell', 'getprop' ]
2019-06-27T05:42:59.864Z native-run:android:utils:adb:getDevices Found adb devices: [ { serial: 'X511XXCH88151959',
    state: 'device',
    type: 'hardware',
    connection: null,
    properties:
     { product: 'CUBOT_KING_KONG',
       model: 'CUBOT_KING_KONG',
       device: 'CUBOT_KING_KONG',
       transport_id: '2' },
    manufacturer: 'CUBOT',
    model: 'CUBOT KING KONG',
    product: 'CUBOT_KING_KONG',
    sdkVersion: '24' } ]
2019-06-27T05:43:01.635Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\emulator\package.xml
2019-06-27T05:43:01.635Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\tools\package.xml
2019-06-27T05:43:01.635Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\build-tools\28.0.3\package.xml
2019-06-27T05:43:01.635Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\patcher\v4\package.xml
2019-06-27T05:43:01.635Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platforms\android-24\package.xml
2019-06-27T05:43:01.635Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platforms\android-27\package.xml
2019-06-27T05:43:01.635Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\platforms\android-28\package.xml
2019-06-27T05:43:01.635Z native-run:android:utils:sdk:getSDKPackage Parsing C:\Users\User\AppData\Local\Android\Sdk\sources\android-28\package.xml
2019-06-27T05:43:01.660Z native-run:android:utils:sdk:api:getAPILevels Discovered installed API Levels: [ { apiLevel: '28',
    packages: [ 'platforms;android-28', 'sources;android-28' ] },
  { apiLevel: '27', packages: [ 'platforms;android-27' ] },
  { apiLevel: '24', packages: [ 'platforms;android-24' ] } ]
2019-06-27T05:43:01.661Z native-run:android:utils:avd:getDefaultAVDSchematic Issue with API 28: Unsatisfied packages within API 28: system-images;android-28;google_apis_playstore;x86
2019-06-27T05:43:01.661Z native-run:android:utils:avd:getDefaultAVDSchematic Issue with API 27: Unsatisfied packages within API 27: system-images;android-27;google_apis_playstore;x86
2019-06-27T05:43:01.661Z native-run:android:utils:avd:getDefaultAVDSchematic Issue with API 24: Unsatisfied packages within API 24: system-images;android-24;google_apis_playstore;x86
Error with Android virtual targets: ERR_UNSUITABLE_API_INSTALLATION: No suitable API installation found.
events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:27015
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
Emitted 'error' event at:
    at emitErrorNT (internal/streams/destroy.js:91:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
    at process._tickCallback (internal/process/next_tick.js:63:19)
kawazoe commented 3 years ago

This is still happening to me on linux in 1.2.2.

foo@ubuntu:~/WebstormProjects/app$ npx ionic cordova run --list
> native-run --list
[native-run] events.js:174
[native-run]       throw er; // Unhandled 'error' event
[native-run]       ^
[native-run] 
[native-run] Error: connect ENOENT /var/run/usbmuxd
[native-run]     at PipeConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
[native-run] Emitted 'error' event at:
[native-run]     at emitErrorNT (internal/streams/destroy.js:91:8)
[native-run]     at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
[native-run]     at process._tickCallback (internal/process/next_tick.js:63:19)
[ERROR] An error occurred while running subprocess native-run.

Looking only for android devices works as expected.