emulator-5554 unauthorized for adb devices

2019-02-17 15:00发布

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.

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

I type adb devices and I see

List of devices attached
emulator-5554   unauthorized

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.

What am I doing wrong?


EDIT

I just connected my android phone to my Mac. When I run adb devices, I see this result

List of devices attached
YLEDU16B18004313    device

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?


EDIT 2

I was able to deploy the app to my android phone by adding these extra steps

  • chmod 755 android/gradlew

  • For some reason, when I type echo $ANDROID_HOME from 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 to my phone.

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.


EDIT 3

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.

4条回答
在下西门庆
2楼-- · 2019-02-17 15:15

Android emulators have by default "Usb Debugging" in settings. You just need to wipe the data of the emulator. Do the following steps. It will work :---

  1. Close the emulator and run the command adb kill-server in the command prompt. If adb is not set in you path then you might run this command from directory where adb is present.
  2. Click on Wipe Data option from avd Actions menu. enter image description here

  3. Now run the emulator. It should work.

查看更多
Rolldiameter
3楼-- · 2019-02-17 15:30

I got my mac system to deploy a react-native build to my physical phone by following Edit 2 in the question.

I got my mac system to deploy a react-native build to my emulator by following Edit 3 in the question.

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.

查看更多
叛逆
4楼-- · 2019-02-17 15:37

This can happen if USB debugging is not enabled on the emulator device.

Go to the emulated device, enable the Developer options and enable USB debugging.

enable USB debugging

查看更多
看我几分像从前
5楼-- · 2019-02-17 15:38

In my case, following steps worked

  1. Wipe data from avd manager
  2. Cold boot now
查看更多
登录 后发表回答