React Native run-android执行失败,react-native doctor无报错求排查
React Native Android 运行无反应问题排查(M2 MacBook Air macOS 14.1.1)
我在MacOS 14.1.1(23B81)的M2 MacBook Air上按照官方指南搭建React Native项目(部分步骤与指南不同,后续说明)。npm run ios可以正常运行,但执行npm run android时仅输出:
info JS server already running. info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor
执行npx react-native@latest doctor后,工具未检测到任何错误或警告:
Common ✓ Node.js - Required to execute JavaScript code ✓ yarn - Required to install NPM dependencies ✓ Watchman - Used for watching changes in the filesystem when in development mode Android ✓ Adb - Required to verify if the android device is attached correctly ✓ JDK - Required to compile Java code ✓ Android Studio - Required for building and installing your app on Android ✓ Android SDK - Required for building and installing your app on Android ✓ ANDROID_HOME - Environment variable that points to your Android SDK installation iOS ✓ Xcode - Required for building and installing your app on iOS ✓ Ruby - Required for installing iOS dependencies ✓ CocoaPods - Required for installing iOS dependencies ✓ ios-deploy - Required for installing your app on a physical device with the CLI ✓ .xcode.env - File to customize Xcode environment Errors: 0 Warnings: 0
不清楚该从何处排查,现将与官方指南不同的配置步骤说明如下:
- 先安装了
brew install --cask zulu11,但出现react-native doctor找不到Android SDK的问题,尝试了两个方案:- 通过Android Studio的SDK Manager下载cmdline-tools
- 创建local.properties文件,内容为
sdk.dir=/Users/<user>/Library/Android/sdk
- 下载并安装了JDK17,更新了.zshrc中的
$JAVA_HOME环境变量,执行java --version和echo $JAVA_HOME确认生效后,再次运行npx react-native@latest doctor仍无异常,但npm run android依旧无法正常执行。
内容的提问来源于stack exchange,提问作者Raw
相关产品推荐
相关产品推荐

