试图在Mac M1上构建Android的React Antive App-错误:未发现仿真器作为“模拟器-list -avds”的输出
我已经在Mac M1上安装了Android Studio
我使用设备管理器在Android Studio中添加了一个虚拟设备
该应用程序从Android Studio内部构建正常...但是,当我从vscode中的命令行运行npx react-npt-intage-nrative and-android
时,我得到了错误no模拟器模拟器的输出-list -avds
但是,当我使用cd〜/library/android/sdk/emulator
和运行命令./ emulator -avd {avd_name}
时,使用cd〜/android/sdk/emulator
时,模拟器开始时,模拟器启动良好.. ...但是,即使在模拟器运行时,命令npx react-native-native android
仍然给出了错误no模拟器作为模拟器-list-list-avds
<<br>
更新04/26 - 我遵循@qqnade的说明,但是我仍然遇到同样的错误...请参阅下面的屏幕截图:
仅从上面的屏幕截图中注意到错误
/bin/sh: adb: command not found
..也是,当我在终端运行echo $ path
时,我会得到以下响应:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/bin:/usr/sbin:/sbin:/sbin:/library/apple/apple/usr/bin
我在其中没有任何对Android的引用,所以我认为那不是一件好事
更新04/26#2
我添加了一个〜/.zshrc
文件,并按照下面的填充:
export ANDROID_HOME="$HOME/Library/Android/sdk"
export
PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
..该求解/bin/sh:adb:adb:command ofer现在我有一个新的:
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew EACCES
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
....至少它现在启动模拟器
更新04/26#3
许多SO帖子告诉我,从Android文件夹(然后清洁)运行以下命令
chmod +x gradlew;
...现在我遇到了一个不同的错误:
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
./gradlew: line 188: syntax error: unexpected end of file
我想知道这是否与我最初在Windows上创建该应用程序有关的事实是否有任何关系。 ...这是我第一次试图在Mac上建立吗?
我在VSCODE中检查了Gradlew文件,它显示为LF(不是CRLF),我知道,在为Mac构建时,它是正确的
I have installed Android Studio on my mac M1
I have added a virtual device in Android Studio using Device Manager
The app builds fine from inside Android Studio......however when I run npx react-native run-android
from command line in VSCode, I get the error No emulators found as an output of emulator -list-avds
However when I navigate to emulator folder using cd ~/Library/Android/sdk/emulator
and run command ./emulator -avd {AVD_NAME}
, the emulator starts fine.....however even with the emulator running, the command npx react-native run-android
still gives the error No emulators found as an output of emulator -list-avds
UPDATE 04/26 - I followed instructions from @qqNade, however I am still getting same error...see screenshot below:
Just noticed from the screenshot above, the error
/bin/sh: adb: command not found
..also, when I run echo $PATH
in terminal, I get the following response:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
I dont see any reference to android in there, so I assume thats not a good thing
UPDATE 04/26 #2
I added a ~/.zshrc
file and populated it as per below:
export ANDROID_HOME="$HOME/Library/Android/sdk"
export
PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
..that solved the /bin/sh: adb: command not found
error, but now I have a new one:
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew EACCES
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
....at least its launching the emulator now
UPDATE 04/26 #3
A number of SO posts told me to run the following command from android folder (and then clean)
chmod +x gradlew;
...now Im getting a different error:
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
./gradlew: line 188: syntax error: unexpected end of file
Im wondering if this has anything to do with fact that I created the app originally on Windows.....and this is the first time Im trying to build on Mac?
I checked gradlew file in VSCode and its showing as LF (not CRLF) which as I understand it is correct when building for Mac
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
需要打开命令提示
您
我还遇到了一个问题,要解决它,
I also faced such a problem, to solve it you need to open a command prompt and enter
after which you need to add this to the file and save
then enter on the command line
我想帮助你。
您在主目录中(可以使用CD $ HOME或CD〜)
之后,当您执行命令vi .bash_profile(或vi .zshrc)之后,
,您应该看到类似的东西
在这一点上,您可以尝试再次执行模拟器-list-avds命令
,是的,echo $ path应该向您显示与Android相关的条目,例如〜/library/android/android/sdk/plancept-tools
echo echo $ android_home,
即使不是工作,我将尝试导航到Android文件夹,并在一个时间下运行命令
:请确保Mac在下面的命令中使用哪个Shell。
进一步阅读
设置开发环境
I want to help you.
You're in the home directory (you can go there with cd $HOME or cd ~)
After that, when you execute command vi .bash_profile (or vi .zshrc), you should see something like that
At this point, you can try to execute emulator -list-avds command again
And yes, echo $PATH should show you entries related with Android like ~/Library/Android/sdk/platform-tools
echo $ANDROID_HOME as well
If still not working, I would try to navigate to android folder and run the commands below one more time
NOTE: Please be sure which shell your mac is using with the command below.
Further reading
setting up development environment
我已经用自制的设置
echo $ path
/bin:/usr/bin:/usr/usr/local/bin:/opt/homebrew/bin:/opt/opt/homebrew/sbin:/usr/usr/local/bin:/usr/bin:/usr/bin :/bin:/usr/sbin:/sbin:/library/apple/usr/bin:/useres/username/username/library/android/sdk/emulator:/useler/useername/username/library/android/android/sdk/platform-
tools获取此错误,
错误无法安装该应用程序。 Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup 。
错误:Spawn ./gradlew eacces
at Process.ChildProcess._handle.Onexit(node:internal/child_process:283:19)
在Onerrornt(节点:内部/child_process:476:16)
在processTickSandRepoxtions(节点:内部/process/task_queues:83:21)
尝试运行此命令,它将使用访问权限更新Gradlew文件,这是M1芯片计算机仅
CD Android
Chmod +X Gradlew,
这解决了我的问题
I have used homebrew for setting up
echo $PATH
/bin:/usr/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/userName/Library/Android/sdk/emulator:/Users/userName/Library/Android/sdk/platform-tools
when we get this error,
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: spawn ./gradlew EACCES
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
try running this command and it will update the gradlew file with access permission, this is for M1 chip machine only
cd android
chmod +x gradlew
This solved my issue