Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

react native - emulator-5554 unauthorized for adb devices

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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!

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...