emulator-5554 未经授权可用于 adb 设备 [英] emulator-5554 unauthorized for adb devices
问题描述
我正在尝试让我的 react-native 项目在 android 模拟器上运行,同时在 Mac 操作系统上运行.它在我的窗户上运行良好.
I'm trying to get my react-native project to run on an android emulator while on a Mac operating system. It worked fine on my windows.
在我的 Mac 上,我转到终端并输入 react-native run-android
并收到错误消息:
On my Mac, I go to terminal and type react-native run-android
and I get the error message:
$ react-native run-android
Scanning 616 folders for symlinks in /Users/John/Documents/myreactnativeproject/node_modules (17ms)
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
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
我输入adb devices
然后我看到
List of devices attached
emulator-5554 unauthorized
我进入我的 android 模拟器的设置,我去设置版本号点击它几次以启用开发者选项.在开发人员选项中,我启用了 USB 调试,禁用了通过 USB 验证应用程序,并将其他所有内容保留为默认值.我关闭了我的 android studio 和模拟器,重新启动了它.但仍然存在上述相同的问题.
I go into the settings of my android emulator, I go to Settings Build Number to tap it several times to enable Developer options. In developer options, I enabled USB debugging, disabled Verify apps over USB, and left everything else as default. I shut down my android studio and emulator, restarted it. But still, the same issues mentioned above.
我做错了什么?
编辑
我刚刚将我的安卓手机连接到了我的 Mac.当我运行 adb devices
时,我看到了这个结果
I just connected my android phone to my Mac. When I run adb devices
, I see this result
List of devices attached
YLEDU16B18004313 device
但是当我运行 react-native run-android
时,我得到了与上面相同的错误.所以也许我的 react-native 设置有问题?
But when I run react-native run-android
, I get the same error as above. So maybe there is something wrong with my react-native set up instead?
编辑 2
通过添加这些额外的步骤,我能够将应用部署到我的安卓手机上
I was able to deploy the app to my android phone by adding these extra steps
chmod 755 android/gradlew
出于某种原因,当我在终端中输入 echo $ANDROID_HOME
时,我得到了结果 /Users/John/Library/Android/sdk
.但是,如果我将 echo $ANDROID_HOME
行添加到我的 android/gradlew
文件中,它不会回显任何内容.当我运行 react-native run-android
命令时,编译器抱怨没有定义 ANDROID_HOME.所以我必须再次输入 export ANDROID_HOME=/Users/John/Library/Android/sdk
,然后运行 react-native run-android
命令并将其部署到我的电话.
For some reason, when I type echo $ANDROID_HOME
into the terminal, I get the result /Users/John/Library/Android/sdk
. But if I add the echo $ANDROID_HOME
line to my android/gradlew
file, it echoes nothing. And when I run the react-native run-android
command, the compiler complains that ANDROID_HOME is not defined. So I have to type export ANDROID_HOME=/Users/John/Library/Android/sdk
again, then running the react-native run-android
command works and deploys it to my phone.
但是,我的模拟器仍然无法工作.我收到的新错误消息是 Skipping device 'emulator-5554' (emulator-5554): Device is UNAUTHORIZED,
.
However, my emulator still doesn't work. The new error message I get is that Skipping device 'emulator-5554' (emulator-5554): Device is UNAUTHORIZED,
.
但至少我有一个临时解决方案,可以用我的手机调试.
But at least I have a temporary solution, and to debug with my phone.
编辑 3
通过进入我的 Android 虚拟设备并删除虚拟设备,我摆脱了 emulator 5554 未授权
错误.然后我重新安装了它.现在我的 adb devices 显示 emulator 5554 device
.而且我无法将应用部署到我的模拟器.
I got rid of the emulator 5554 unauthorized
error by going into my Android Virtual Devices and deleting the virtual device. Then I re-installed it. And now my adb devices shows emulator 5554 device
. And I am not able to deploy the app to my emulator.
推荐答案
按照问题中的 Edit 2,我让我的 mac 系统将 react-native 构建部署到我的物理手机上.
I got my mac system to deploy a react-native build to my physical phone by following Edit 2 in the question.
按照问题中的编辑 3,我让我的 mac 系统将 react-native 构建部署到我的模拟器.
I got my mac system to deploy a react-native build to my emulator by following Edit 3 in the question.
我认为这个问题通常是由于将我的项目从 Windows 开发区移到 Mac 开发区引起的.然后可能发生了不同问题的组合,导致构建在每种情况下都失败.
I think the issue was generally caused by moving my project from a Windows dev area to Mac dev area. Then probably a combination of different issues happened that cause builds to fail for each situation.
这篇关于emulator-5554 未经授权可用于 adb 设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!