React Native adb reverse ENOENT [英] React Native adb reverse ENOENT

查看:28
本文介绍了React Native adb reverse ENOENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让 React-Native 与 Android V4.2.2 (Genymotion) 一起使用,但我无法在模拟器上测试该应用程序.当我运行 react-native run-android 时,出现此错误 Could not run adb reverse: spawnSync

这是一个日志

JS 服务器已经运行.运行 ~/Library/Android/sdk/platform-tools/adb 反向 tcp:8081 tcp:8081无法反向运行 adb:spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT在设备上构建和安装应用程序 (cd android && ./gradlew installDebug...FAILURE:构建失败,出现异常.* 什么地方出了错:配置项目:app"时出现问题.>SDK 目录~/Library/Android/sdk"不存在.* 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪.使用 --info 或 --debug 选项运行以获得更多日志输出.构建失败总时间:3.785 秒无法在设备上安装该应用程序,请阅读上面的错误了解详情.确保您有一个正在运行的 Android 模拟器或已连接的设备设置你的 Android 开发环境:https://facebook.github.io/react-native/docs/android-setup.html

注意:在日志中它说 SDK 目录不存在,我仔细检查了我是否在该目录中安装了 SDK.

我在执行 adb devices

时找到了我的 android 模拟器

连接的设备列表192.168.56.101:5555 设备

我已经尝试了 Stack Overflow 帖子中的以下步骤,但仍然没有运气https://stackoverflow.com/a/38536290/4540216

解决方案

我遇到了同样的问题.我再次更新了我的 ANDROID_HOME 环境变量,它对我有用.

按照这个React-原生 android-setup 文档

例如:

export ANDROID_HOME=~/Library/Android/sdk

Windows:

set ANDROID_HOME=c:/Users/whoever/AppData/Local/Android/Sdk

ma​​cOS Mojave 及更早版本或 bash 用户:

1 - 打开您的 bash 配置文件:

打开 .bash_profile

将此添加到您的 bash_profile:

 export ANDROID_SDK=/Users//Library/Android/sdkexport PATH=/Users//Library/Android/sdk/platform-tools:$PATH

保存并关闭

编译您的更改

source ~/.bash_profile

对于 macOS Catalina 和 zsh 用户:

从 macOS Catalina 开始,您的 Mac 使用 zsh 作为默认登录 shell 和交互式 shell.您也可以将 zsh 设为早期版本的 macOS 中的默认值.

在您的 Mac 上:

打开您的 .zshrc 文件:

打开 ~/.zshrc

如果 .zshrc 文件不存在,您需要使用 touch & 创建一个打开.

touch ~/.zshrc

将此添加到您的 .zshrc 文件

export ANDROID_SDK=/Users//Library/Android/sdkexport PATH=/Users//Library/Android/sdk/platform-tools:$PATH

保存并关闭

编译您的更改

source ~/.zshrc

更新了 macOS Catalina 和 zsh 用户的答案.

I am trying to get React-Native to work with Android V4.2.2 (Genymotion) but I am unable to test the app on the Emulator. When I ran react-native run-android, I get this error Could not run adb reverse: spawnSync

Here is a log

JS server already running.
Running ~/Library/Android/sdk/platform-tools/adb reverse tcp:8081 tcp:8081
Could not run adb reverse: spawnSync ~/Library/Android/sdk/platform-tools/adb ENOENT
Building and installing the app on the device (cd android && ./gradlew installDebug...

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> The SDK directory '~/Library/Android/sdk' does not exist.

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

BUILD FAILED

Total time: 3.785 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

NOTE: In the log it saids SDK directory does not exist, I have double check that I do have the SDK installed in that directory.

I found my android emulator when executing adb devices

List of devices attached
192.168.56.101:5555 device

I have tried the following steps from Stack Overflow post, but still no luck https://stackoverflow.com/a/38536290/4540216

解决方案

I got the same issue. I updated my ANDROID_HOME env variable again it worked for me.

Follow this React-native android-setup documentation

ex:

export ANDROID_HOME=~/Library/Android/sdk

Windows:

set ANDROID_HOME=c:/Users/whoever/AppData/Local/Android/Sdk

macOS Mojave and earlier or bash users:

1 - Open your bash profile:

open .bash_profile

Add this to your bash_profile:

 export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
 export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH

Save and close

Compile your changes

source ~/.bash_profile

For macOS Catalina and zsh users:

Starting with macOS Catalina, your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.

On your Mac:

Open your .zshrc file:

open ~/.zshrc

If .zshrc file not exist, you need to create one using touch & open.

touch ~/.zshrc

Add this to your .zshrc file

export ANDROID_SDK=/Users/<your_computer_name>/Library/Android/sdk
export PATH=/Users/<your_computer_name>/Library/Android/sdk/platform-tools:$PATH

Save and close

Compile your changes

source ~/.zshrc

Edit: Updated answer for macOS Catalina and zsh users.

这篇关于React Native adb reverse ENOENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆