Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expo with Android Studio Emulator error: "Error running adb: This computer is not authorized to debug the device"

I am trying to connect an Android Studio Emulator to my expo application, but I get this error message:

Couldn't start project on Android: Error running adb: This computer is not authorized to debug the device. Please follow the instructions here to enable USB debugging: https://developer.android.com/studio/run/device.html#developer-device-options. If you are using Genymotion go to Settings -> ADB, select "Use custom Android SDK tools", and point it at your Android SDK directory.

Does anyone know what to do with this?

Thanks!

like image 705
Axel Øvrebø Harstad Avatar asked Sep 29 '18 00:09

Axel Øvrebø Harstad


3 Answers

What has worked for me just now:

  1. Go to tools.
  2. Select avd in Android studio.
  3. Select your emulator.
  4. Wipe data.
  5. Click "Start again".
like image 153
Valar Morghulis Avatar answered Oct 18 '22 07:10

Valar Morghulis


tldr:
Look at the emulator "screen" and accept the prompt asking if you want to allow debugging.


I got that message you described in the question when I did the following:

  1. In Android Studio Virtual Device Manager (VDM), start the emulated device
  2. run npm start (which runs expo start)
    • expo Metro Bundler runs (command line and browser)
  3. in expo: select Android emulator
  4. in expo: see the same error that you posted

The provided link didn't seem to pertain to the emulator.

I didn't realize at first, but the solution was waiting on the screen of the emulated device. It was quietly showing a standard Android permission prompt, asking for permission to allow debugging the device. This prompt is described in the "note" in https://developer.android.com/studio/command-line/adb#Enabling,

Note: When you connect a device running Android 4.2.2 or higher, the system shows a dialog asking whether to accept an RSA key that allows debugging through this computer. This security mechanism protects user devices because it ensures that USB debugging and other adb commands cannot be executed unless you're able to unlock the device and acknowledge the dialog.

This of course I would expect for a phone, but didn't think of it for an emulator.

Once I granted that permission in the emulated phone, then expo proceeded to run on the emulator.

like image 6
Daryn Avatar answered Oct 18 '22 08:10

Daryn


I discovered that "USB Debugging" had been turned off in the Developer Options of the emulator. Turning it on fixed the problem. No idea how it came to be turned off.

like image 5
Mitch Avatar answered Oct 18 '22 08:10

Mitch