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!

Upvotes: 32

Views: 84945

Answers (19)

Code ninja
Code ninja

Reputation: 190

There are two ways of doing this.

  1. Wipe SDK data
  2. Kill a running emulator

First step: Open android studio > virtual device > click on more_vert > select wipe data

Second step: Open your command prompt and use this command

>> adb -e emu kill

or

If Expo CLI is running, stop it with ctrl+c -- this will stop ADB.

Disconnect your Android device from the computer. Revoke USB Debugging on the device: Open the Settings app on your device. Navigate: Developer Options -> select Revoke USB debugging authorizations. Reconnect the device: The device will prompt you to agree to connect the computer. You must confirm it. The computer is now authorized for debugging!

Upvotes: 0

0xC0DEGURU
0xC0DEGURU

Reputation: 1792

I spent an hour to find out how to fix that problem, when I finally realized that I plugged my phone to get charged into the same computer I work on while using the emulator.

Upvotes: -1

Premo89
Premo89

Reputation: 54

Updating expo-cli globally fixed it for me. Remember to run it with admin privileges then restart android studio and wipe android data.

 npm install -g expo-cli

Upvotes: 0

Bilal Mohmand
Bilal Mohmand

Reputation: 51

This computer is not authorized for developing on. https://expo.fyi/authorize-android-device

I resolved this issue by choosing a device without the google play store (play button).

Upvotes: 0

Abhishek Singh
Abhishek Singh

Reputation: 103

I know the exact answer of this question The Problem is your AVD manager is not set to the path Than you have add to path first is ANDROID_SDK_ROOT and PLATFORM-TOOLS HERE I GIVE ALL THE LOCATION PLATFORM TOOLS - C:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk\platform-tools ANDROID_DK_ROOT - C:\Users\YOUR_USERNAME\AppData\Local\Android\Sdk ADD in path (SEARCH ON START EVIRONMENT VARIABLES) and than restart your pc

Upvotes: 2

Ivaylo
Ivaylo

Reputation: 7

today I experience the same issue but I have fixed it very easily. Try the solution it might work for you too. Many developers have wsl or windows subsystem for Linux and it is using a VM and I found it blocks the android sim and causes the error "Error running adb". The solution I found was to open my PowerShell and type "wsl --shutdown". After rerunning the script for android emulation from expo it worked like a charm. Hope I helped.

Upvotes: 0

KushalSeth
KushalSeth

Reputation: 4729

I was facing the same issue. I am using windows machine. Steps I did to resolve:

  1. I have added the environment variable.

    • To Add System Variable, search environment variable in Windows (or search google how to open environment variables, if you are on some other system or cmd). In the system variable add the Variable: ANDROID_SDK_ROOT to your android studio path, like in my case it is: C:\Users\kushalseth\AppData\Local\Android\Sdk

    enter image description here

    • At the same place, i.e. System Variable, Click on Path and add this, it already doesn't exists. Please check this path in your system: C:\Users\kushalseth\AppData\Local\Android\Sdk\platform-tools

enter image description here

To Validate, run the command: adb in command prompt.

enter image description here

(Also check, if you are logged-in to expo from cmd. This is an extra precautionary step.)

Upvotes: 2

Suresh
Suresh

Reputation: 1

  1. Open the Android Virtual Device Manager(AVD Manager).

  2. And in your current virtual device on the right side, there will be a dropdown icon, and click that icon.

  3. In the dropdown list there will be a Wipe Data and click it.

  4. And Run your Emulator

Upvotes: 0

Kishore Kumaran
Kishore Kumaran

Reputation: 1

For Windows:

Select 'Wipe Data' option in the AVD manager and restart again.

Or

Add SDK tools path eg: E:\Android\SDK and SDK platform-tools path eg: E:\Android\SDK\platform-tools in the windows system environmental variables. (In my case I have installed SDK inside the E directory)

Upvotes: 0

Nalin Athukorala
Nalin Athukorala

Reputation: 137

  1. First close your opened android emulator.
  2. Open android studio and go to AVD manager.
  3. Select virtual device which you have faced trouble, under actions select wipe data option.
  4. Give ok for the opened window.
  5. These steps worked for me.

Upvotes: 2

Tilmann
Tilmann

Reputation: 31

I was using the emulator from Android Studio for my expo projects. It used to work properly. Then, one day the emulator stopped interacting with expo, always saying:

This computer is not authorized for developing on . https://expo.fyi/authorize-android-device

The advices given on that link did not help. Revoking the USB permissions did not help either. Even newly created Devices in AVD Manager did not let me connect.

However, finally this answer solved the problem for me

Choosing a device from AVD Manager without Google Play Store on it let me connect expo to the emulator, again.

Note: I could not get to the root cause of the problem, so I am still not sure why it stopped working all of a sudden. I upgraded to Expo SDK 39 at the same time that I switched from managed workflow to bare workflow. So, one of those circumstances may have caused the problem.

Upvotes: 1

Rajitha Udayanga
Rajitha Udayanga

Reputation: 1742

  1. Go to android studio
  2. Open AVD manager
  3. Wipe data on your emulator (Clicking dropdown icon in actions column )
  4. Launch emulator

enjoy :)

Upvotes: 3

kashyapbaiju
kashyapbaiju

Reputation: 39

I had the same issue and it almost took one day to figure that out. First try enabling the USB debugging mode, still if it shows the same error try the next step. Try to check ADB devices in cmd, if it doesn't work go and change the environmental variables of the android SDK manager.

And refer this link https://medium.com/@vsburnett/running-a-react-native-app-on-an-android-virtual-device-with-expo-in-windows-10-9e0976db5f50

Upvotes: 0

Salad.Guyo
Salad.Guyo

Reputation: 3415

Enable Virtualization on your machine

Enter your BIOS settings on boot of your machin and enable Virtualization Technology. The location may differ depending on your processor.

enter image description here

Upvotes: -3

Élie
Élie

Reputation: 171

I had this problem today, I just disabled USB debugging and enabled it again. Worked.

Upvotes: 6

Valar Morghulis
Valar Morghulis

Reputation: 287

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

Upvotes: 27

Muhammad Arslan Akhtar
Muhammad Arslan Akhtar

Reputation: 557

Try running a lower version of the android emulator from android studio. I was getting the same error while trying to run the latest expo-react-native app on android emulator version 9.0 Pie. I got it working by running a lower version of the android emulator version 8.1 Oreo. You also have to tab allow/ok on the phone screen when asked for enable USB Debugging during the app booting on the emulator.

Upvotes: 0

Daryn
Daryn

Reputation: 5107

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.

Upvotes: 8

Mitch
Mitch

Reputation: 661

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.

Upvotes: 5

Related Questions