react-native-community / cli

React Native command line tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cannot start Android emulator version 34.1.20.0 (build_id 11610631)

doothez opened this issue · comments

Environment

» npx react-native info

info Fetching system and libraries information...
System:
OS: macOS 14.4.1
CPU: (12) arm64 Apple M2 Pro
Memory: 45.98 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.16.0
path: ~/.nvm/versions/node/v18.16.0/bin/node
Yarn:
version: 1.22.22
path: /opt/homebrew/bin/yarn
npm:
version: 9.5.1
path: ~/.nvm/versions/node/v18.16.0/bin/npm
Watchman:
version: 2024.03.18.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods: Not Found
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.4
- iOS 17.4
- macOS 14.4
- tvOS 17.4
- visionOS 1.1
- watchOS 10.4
Android SDK:
API Levels:
- "24"
- "26"
- "27"
- "28"
- "29"
- "30"
- "31"
- "32"
- "33"
- "33"
- "33"
- "34"
Build Tools:
- 23.0.3
- 28.0.3
- 29.0.2
- 30.0.2
- 30.0.3
- 31.0.0
- 32.0.0
- 33.0.0
- 33.0.1
- 33.0.2
- 34.0.0
- 35.0.0
System Images:
- android-29 | ARM 64 v8a
- android-29 | Intel x86 Atom
- android-29 | Intel x86_64 Atom
- android-29 | Google APIs ARM 64 v8a
- android-29 | Google APIs Intel x86 Atom
- android-29 | Google APIs Intel x86_64 Atom
- android-29 | Google Play ARM 64 v8a
- android-29 | Google Play Intel x86 Atom
- android-29 | Google Play Intel x86_64 Atom
- android-30 | AOSP ATD ARM 64 v8a
- android-30 | Intel x86 Atom_64
- android-30 | Google APIs ARM 64 v8a
- android-30 | Google APIs ATD ARM 64 v8a
- android-31 | Google APIs ARM 64 v8a
- android-31 | Google APIs Intel x86_64 Atom
- android-32 | Google Play Intel x86 Atom_64
- android-33 | Google Play ARM 64 v8a
Android NDK: 20.1.5948944
IDEs:
Android Studio: 2023.2 AI-232.10227.8.2321.11479570
Xcode:
version: 15.3/15E204a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /usr/bin/javac
Ruby:
version: 2.7.6
path: /Users/sung.lee/.rvm/rubies/ruby-2.7.6/bin/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.5
wanted: 0.73.5
react-native-macos: Not Found
npmGlobalPackages:
"react-native": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false

Description

Since Android emulator version 34.1.20.0 (build_id 11610631)'s INFO log is opened,
node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/tryLaunchEmulator.js
getEmulators cannot return proper AVDS name,
and because of that react-native run-android CLI cannot start emulator.

Reproducible Demo

» react-native run-android

> connectedCoffee@0.0.1 android
> react-native run-android

info Launching emulator...
error Failed to launch emulator. Reason: The emulator (INFO    | Storing crashdata in: /tmp/android-sung.lee/emu-crash-34.1.20.db, detection is enabled for process: 30977) quit before it finished opening. You can try starting the emulator manually from the terminal with: /Users/sung.lee/Library/Android/sdk/emulator/emulator @INFO    | Storing crashdata in: /tmp/android-sung.lee/emu-crash-34.1.20.db, detection is enabled for process: 30977.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.

» emulator
INFO    | Storing crashdata in: /tmp/android-sung.lee/emu-crash-34.1.20.db, detection is enabled for process: 37429
INFO    | Android emulator version 34.1.20.0 (build_id 11610631) (CL:N/A)
ERROR   | No AVD specified. Use '@foo' or '-avd foo' to launch a virtual device named 'foo'

» emulator -list-avds
INFO    | Storing crashdata in: /tmp/android-sung.lee/emu-crash-34.1.20.db, detection is enabled for process: 37459
Pixel_7a_API_33

This issue can be fixed with below change in the node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/tryLaunchEmulator.js

const getEmulators = () => {
  try {
    const emulatorsOutput = _execa().default.sync(emulatorCommand, ['-list-avds']).stdout;
    return emulatorsOutput.split(_os().default.EOL)
      .filter(name => name !== '' && !name.startsWith('INFO    | '));
  } catch {
    return [];
  }
};