Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
npx react本机运行的android不';t启动emulator并且不';如果emulator正在运行,则无法运行_Android_Macos_React Native_Android Emulator_React Native Android - Fatal编程技术网

npx react本机运行的android不';t启动emulator并且不';如果emulator正在运行,则无法运行

npx react本机运行的android不';t启动emulator并且不';如果emulator正在运行,则无法运行,android,macos,react-native,android-emulator,react-native-android,Android,Macos,React Native,Android Emulator,React Native Android,我已经使用react native 0.63创建了一个新项目 当我在ios模拟器上运行时,一切正常 但当尝试在android上运行它时,它不起作用,并给我这个错误 FAILURE: Build failed with an exception. * What went wrong: Could not determine the dependencies of task ':app:installDebug'. > SDK location not found. Define locat

我已经使用react native 0.63创建了一个新项目 当我在ios模拟器上运行时,一切正常 但当尝试在android上运行它时,它不起作用,并给我这个错误

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:installDebug'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/Volumes/SSD2/developer/MyProject/AwesomeProject/android/local.properties'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
我喜欢本地人

这是我本地医生的输出

✓ Node.js
 ✓ npm
 ✓ Watchman - Used for watching changes in the filesystem when in development mode

Android
 ✓ JDK
 ✓ Android Studio - Required for building and installing your app on Android
 ✖ Android SDK - Required for building and installing your app on Android
   - Versions found: N/A
   - Version supported: 29.0.2
 ✖ ANDROID_HOME

iOS
 ✓ Xcode - Required for building and installing your app on iOS
 ✓ CocoaPods - Required for installing iOS dependencies
 ✓ ios-deploy - Required for installing your app on a physical device with the CLI

Errors:   2
Warnings: 0
如果我运行npx react native start,那么应用程序将从android studio平稳运行

编辑 如果我从terminal source.bash\u配置文件运行项目

emulator启动但项目未运行

"--no-jetifier" flag.
Jetifier found 5194 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
info Installing the app...
env: sh\r: No such file or directory

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
env: sh\r: No such file or directory

看起来您需要设置ANDROID_HOME环境变量

将以下行添加到$HOME/.bash_配置文件或$HOME/.bashrc(如果您使用的是zsh,则为~/.zprofile或~/.zshrc)配置文件:

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
键入source$HOME/.bash\u profile for bash或source$HOME/.zprofile将配置加载到当前shell中。验证是否已通过运行echo$ANDROID_HOME设置了ANDROID_HOME,并通过运行echo$path将适当的目录添加到您的路径中

请确保使用正确的Android SDK路径。您可以在Android Studio的“首选项”对话框中的“外观和行为”下找到SDK的实际位置→ 系统设置→ Android SDK

参考资料:

  • 三,。配置ANDROID_HOME环境变量

但是我确定我在文件中设置了安卓主页:bash\u profile当你在终端中运行'echo$ANDROID\u HOME'时,你会得到什么?我得到的只是(ANDROID\u HOME)确保你在一开始就有美元符号,比如
$ANDROID\u HOME
。安卓Sdk的问题就在这里100%非常感谢你