emulator-5554 unauthorized for adb devices
Asked Answered
P

13

37

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 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.

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.

Philosophical answered 23/10, 2017 at 20:52 Comment(15)
Can you add the complete error message please? There might be another reason since it says "read the error above for details"Demmy
@Demmy ok I've put in all the error messages that I received right after the react-native run-android command. I don't think there's anything useful therePhilosophical
Does the react packager start before the error?Demmy
@Demmy it says React packager ready. Loading dependency graph, done.Philosophical
I just tried to be sure, I created a new project and run react-native run-android without starting any emulators. Command goes through all the building stages and then gives an error about the not connected emulator. If you moved your android files from windows there might be some conflict that cause the problem. Did you try running cd android && ./gradlew clean?Demmy
@Demmy I get permission denied when I ran the ./gradlew clean. So then I tried sudo ./gradlew clean and I get this error ./gradlew: command not foundPhilosophical
@Demmy hold on, I just chmod 755 the gradlew, now it's doing somethingPhilosophical
Even thought if it solves the problem you shouldn't be needing to do this. There might be some problem with your initial installment but I'm not sure what is it.Demmy
When you run react-native run-android it tries to run (cd android && ./gradlew installDebug) and it might be also getting permission denied error and can't complete the command.Demmy
@Demmy ok interesting. Yes now I get a different issue saying ANDROID_HOME isn't defined. But from my terminal if I type echo $ANDROID_HOME I see the value /Users/John/Library/Android/sdk. And I confirmed that this path actually exists.Philosophical
I'm not that good with linux or mac but can it be another permission issue like can't even get the variables?Demmy
Can I suggest you to try something? Can you run the app from Android Studio and not from the terminal command? If running from Android Studio doesn't start the packager you can start it with react-native start and then run the app.Demmy
@Demmy OK, I got things to deploy to my phone. Emulator continues to be a problem. I added an Edit 2 explaining how I got things to work.Philosophical
I'm glad that you found a temp solution but I still think that something is wrong in your installation. Creating a new project with the same version of react-native that you are using and testing if its gonna start from the command right away without any change might help to see if the problem is with your project or your os or something else.Demmy
@Demmy ok I got rid of the emulator 5554 unauthorized message and now it shows emulator 5554 device, and it can now accept the react-native build. Everything works now! I explain in EDIT 3.Philosophical
P
0

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.

Philosophical answered 25/10, 2017 at 15:4 Comment(0)
M
68

In my case, Create a Virtual Device with Google APIs Image, not Google Play Image worked for me.

The problem occurs the only emulator that runs on Android Pie others don't.

In Android Studio

  1. Open an Android Virtual Device Manager.
  2. Create a new Virtual Device.
  3. Select any Hardware you want.
  4. Select any System Image which the Target is "(Google APIs)" not "(Google Play)" (If you don't found. Try to look at "x86 Images" tab or "Other Images" tab)
  5. Done!
Moradabad answered 18/3, 2019 at 14:4 Comment(5)
Item number 4 solved my problem i was using Google Play as system image just changed it to Google APIs.Causeuse
thank you, it worked with Google APIs as system imageHanse
In Android S Preview it is still the same (use Google API).Diannadianne
Not applicable if you want to try google play services !Satirize
Is there any alternative? I need an updated Chrome for my tests, and there's no easy way to update Chrome on Google APIs images.Legitimatize
H
49

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.

Hymettus answered 10/2, 2018 at 15:34 Comment(5)
my emulator has not enabled "Usb Debugging" by default. I am using not studio but Android SDK Manager and this step doesnt work in me.Penthouse
This answer is bestWaxler
Worked for me by following your steps.Tenaculum
I tried the adb command several places but it doesn't seem to be installed/found. I'm using Android Studio 3.5.1Yesterday
If you have android SDK installed then adb can be found in platform-tools folder inside sdkHymettus
M
25

create new Virtual Device, and make sure you choose Google API's. enter image description here

run the new device!. this should work

enter image description here

Mantelet answered 3/4, 2019 at 5:12 Comment(0)
D
14

In my case, following steps worked

  1. Wipe data from avd manager
  2. Cold boot now
Diminution answered 7/2, 2018 at 9:29 Comment(0)
O
7

I managed to authenticate the adb on a Pixel 2, Android 9.0 (Google Play), API 28, x86_64 virtual device (Intel HAXM). The problem should be related to the Extended Controls (the 3 dots bottom icon menu, when the virtual device is booted), the Google Play menu, that is checking the version of the Google Play services. When adb is not 'unauthorized', this page is displaying the correct version, and the Update button opens inside the phone the Play Store with the Play Services app, so you can update it.

The steps I took to be able to authenticate are:

  1. Make sure the USB debugging is turned ON in Dev setting
  2. Revoke the USB debugging authorizations
  3. Make sure the Extended Controls > Settings > Advanced > Open GL options are set to the: 'Desktop native OpenGL' and 'Renderer maximum (up to OpenGL ES 3.1)', so the emulator interface, animations, etc, are fast!
  4. Power off the emulator
  5. In 'Your Virtual Devices' in Android Studio, click the down arrow in Actions > Select 'Cold Boot Now'
  6. When the device boot, you have to be fast, the dialog to remember and accept the USB connection will show and disappear for like less than 1 second (again I guess related to some automation scripts kicking, idn).

If you manage to click the 'remember' and 'ok' checkbox and button before the dialog disappears, you are done. Else you have to Power Off and Cold Boot again.

After that, don't wipe your emulator, else you'll have to do that insane race clicking again!

Otisotitis answered 25/3, 2019 at 11:33 Comment(1)
I'm having the same issue, with the same system image... the "authorize" screen appears after the cold boot, but lasts less than a second and then disappears... will try to find a way to it to reappear. Thanks, by the way!Reliant
S
3

Creating an emulator with graphics set to "Software - GLES 2.0" worked for me (Nexus 6 image).

I was initially using a Nexus 5X image which didn't allow me to select the graphics option.

NOTE: I went through the steps mentioned in EDIT 2 and EDIT 3 by the OP before doing this.

Seemly answered 14/3, 2019 at 13:37 Comment(0)
S
3

I run adb kill-server and adb devices. the device will back again. for Emulator, the default settings is debug enabled

Superscribe answered 14/4, 2020 at 7:36 Comment(0)
C
2

2022 answer

What a shame of thread: so many "answers", comments and upvotes and none worked. Nobody simply mentioned that the "adb unauthorized" is caused by the adb keys stored in ~/.android/adbkey and ~/.android/adbkey.pub After deleting and recreating them, the problem was solved.

Credit: Android Emulator Unauthorized

Chandachandal answered 31/1, 2022 at 17:28 Comment(2)
Not always the case. I could not fix the problem with the old emulator from SDK 25 and Android 7.1.1, it worked fine with Android 7.0.Purulence
that's not really an answer either, why would this happen?Meza
F
1

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

Forfeit answered 30/6, 2018 at 23:46 Comment(1)
It hasn't worked for me for years, but on API 29 emulator I created an avd from Google APIs image, like in answers above.Diannadianne
F
1

I had to create a new emulator with Google Api. Wiping data didn't work for me.

Further answered 24/10, 2019 at 5:25 Comment(0)
P
0

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.

Philosophical answered 25/10, 2017 at 15:4 Comment(0)
P
0

Deleting emulator and creating it again helped me on Ubuntu

Polyglot answered 8/2, 2020 at 8:21 Comment(0)
A
0

I solved Problem

add ANDROID_SDK_HOME to environment variable

ANDROID_SDK_HOME  = D:\sdk

and unplug device

and use new cmd

Ant answered 17/8, 2022 at 7:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.