50

I read the answers "unable to locate adb" using Android Studio and Error:Unable to locate adb within SDK in Android Studio and it didn't solve my problem.

I use the 4.0 android-studio and Ubuntu 18.04

When I click on "launch this AVD in the emulator", I get an error message "Unable to locate adb". I did look in the Android/Sdk/platform-tools, I have an "adb" executable.

After the "unable to locate adb" error message, the AVD still launches. But, when I try to run my react native app on it, I get the error

error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details. Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

I'm pretty sure the react-native part is fine, but that route to the emulator is not the same as before.

It was working before. Yesterday, out of the blue, when I launched my android-studio, it "restarted" (showing me the install wizard, etc), and it seems it messed up its configuration.

EDIT: [bad way] I created a new ubuntu user, re-install android studio + react-native. I still get the error message, still the AVD launches, but now React-native can install the app on it. So, now I can work with my new user, but I did not fix the problem.

EDIT2: [good way] @jpatmore fixed the android-studio part (see his answer). The react-native was still not working. There was probably some parameter of android-studio 3.6 still in the [my project]/android/[gradle or something] I cloned my repo in another folder, do another "npm install", "react-native link", and it was working.

Arnaud Fouchet
  • 933
  • 1
  • 7
  • 14

10 Answers10

124

A couple of days after posting the above solution, the problem returned on my Windows system.

Finally after several hours of investigation I think I have another solution for everyone having issues with AVD Manager "Unable to locate adb".

I know we have the setting for the SDK in File -> Settings -> Appearance & Behavior -> System Settings -> Android SDK. This it seems is not enough! It appears that Android Studio (at least the new version 4) does not give projects a default SDK, despite the above setting.

So, you also (for each project) need to go to File -> Project Structure -> Project Settings -> Project, and select the Project SDK, which is set to [No SDK] by default.

If there's nothing in the drop-down box, then select New, select Android SDK, and navigate to your Android SDK location (normally C:\Users[username]\AppData\Local\Android\Sdk on Windows). You will then be able to select the Android API xx Platform. You now should not get this annoying adb error.

HTH

SadSack963
  • 2,039
  • 2
  • 15
  • 10
  • 4
    thanks. this worked for me. Annoying as it is, at least i got past the error. – KC Coder Jul 26 '20 at 00:54
  • 1
    I had the abd.exe in my folders and I had excluded them from the anti virus and still could not get it working. This is what solved the problem for me, thanks for the answer. – Stoimen Jul 28 '20 at 14:39
  • Thanks this fixed it – Joseph Aug 10 '20 at 19:03
  • 2
    There is no File -> Project Structure -> Project Settings -> Project in AS 4 – Ajna Aug 28 '20 at 05:42
  • @Ajna Use File -> Project Settings (Ctrl+Alt+Shift+S on Windows). This will open a dialog box entitled Project Structure. In the list on the left pane, under the Project Settings heading, you should see the Project entry. Click on that and in the right hand pane you can set your Project SDK. – SadSack963 Aug 30 '20 at 17:23
  • Thanks, that worked for me as well. What a bad design! – Andrew Oct 07 '20 at 06:21
  • On Linux you have a very similar path: `/home/YourUsername/Android/Sdk/` – Awaaaaarghhh Oct 19 '20 at 17:59
  • The File Structure worked for me. Thanks! – David Bolton Apr 27 '21 at 08:10
  • There's no "Project Settings" menu item for me. There's an "SDK Location", but it only seems to let me define the path - not the "API xx platform". – velkoon Sep 23 '21 at 19:53
  • Thank you very much, after hours of searching I finally found this works. All other threads asking reinstalling SDK not working at all. – beedrill Dec 22 '21 at 20:22
  • That worked. This should be marked as answer. – James Poulose Jan 11 '22 at 01:14
54

With Android Studio 4.1.1, to make the solution more illustrative:

Process image

Iván Yoed
  • 3,878
  • 31
  • 44
51

I started getting this error after updating Android Studio from version 3.6.3 to 4.0. It didn't stop the emulator working, but it was vaguely annoying.

I checked that adb.exe was in the folder C:\Users[username]\AppData\Local\Android\Sdk\platform-tools. I also ran it in a command-line to prove that the exe worked OK.

Finally after a bit of a struggle I found a solution:

Start the SDK Manager, File menu -> Settings -> Appearance & Behavior -> System Settings -> Android SDK, SDK Tools tab (Or click the cube with blue down arrow icon in the toolbar).

Firstly I updated the Android SDK Platform-Tools (now v30.0.2). This didn't fix the problem. I also tried manually deleting the platform tools folder and reinstalling.

Eventually I decided to click the "Edit" link next to the "Android SDK Location" box. This opens a new dialog for SDK Components Setup. How well hidden is that?!?! I had always assumed it was to edit the SDK path!

You should now see that Android SDK - (installed) has a tick in the checkbox, as do any SDK Platforms you have. Click on the Next button and your SDK will update. Problem solved.

HTH

SadSack963
  • 2,039
  • 2
  • 15
  • 10
  • Thanks, it fixed the android-studio problem. The react-native was still crashing, I fixed it by cloning my code, redo react-native install & co. I guess some parameter stayed in the android/gradle or something – Arnaud Fouchet Jun 07 '20 at 12:43
  • 4
    While this is the accepted answer - read below for a better answer that has more upvotes. – jaredbaszler Sep 22 '20 at 19:20
  • Wow, that was helpful. Thank you very much. The constant error pop always just bugged me a bit xD – Manthan_Admane Sep 25 '20 at 22:03
  • using this method, first i checked that my sdk is already installed. but i proceed to click next, it says nothing to do, but then my problem solved.. how weird – thekucays Oct 20 '20 at 08:16
  • 3
    When I try this method the "Android SDK - (installed)" checkbox is not ticked and I cannot tick it. The only ticked checkbox is "Android SDK Platform" but when I click next it says it has nothing to do and nothing changes. – Jean Paul Nov 01 '20 at 13:58
  • Thanks a lot! This is infuriatingly obscure, though. – kioopi Apr 28 '21 at 15:14
4

For me (Android-Studio on Ubuntu-18.04), it was caused by wrong Android Project SDK with emulators's API versions.

To correct it, first go to File->Settings->Appearance & Behavior->System Settings->Android SDK, in which check SDK Platforms->API Level to see what (API versions) have been installed, if none, install one.

Then, go to Project Structure->Module->Properties and configure Compile SDK Version and Build Tool Version to be consistent with what have been installed.

Yuqi
  • 391
  • 4
  • 4
2

im using windows 8 and i just got the same problem, i solved this by adding the adb.exe in the path variable.

  1. open your adb.exe in C:\Users\your-user\AppData\Local\Android\Sdk\platform-tools\adb.exe and copy the path
  2. paste it in the the environment variable named path.
  3. restart android studio
1

For this problem, I did the following to finally solve it:

  1. In Android Studio, navigate to File > Project Structure....first pic In the Project panel, specify your Project SDK. In my case, I select Android API 30 Platform. Then, go to SDKs panel under Platform Settings, specify your Build Target. In my case, it's Android API 29.second pic

  2. Next I navigate to GeneratedPluginRegistrant(Refer to this picture). Click Setup SDK. Then restart Android Studio.third pic

  3. Lastly, I installed Intel Graphics Driver from this website. It will automatically update your graphics driver and will take quite a long time.fourth pic After the update was finished, restart your computer/laptop.

This solution worked for me and I hope that you too! :)

Harriseu
  • 11
  • 2
0

In the "Advanced Settings" section of your Android device; When "Verify applications via USB = Enable" and "Select USB Configuration = MIDI", the connection between the computer and the android device is provided. The result is run!

0

My little contribution. I have 10.0 (R) and 7.1.1 (Nougat) SDKs installed. Also, installed and uninstalled many times my Android SDK Platform-Tools. Now it is at version 30.0.4. And I made the Edit to SDK Location. Nothing worked. So I noticed I had another directory at /home//Android/Sdk/platforms. It was 9.0 (Pie). It was half installed (maybe some error in the past). So, I did installed completely. It worked. :)

0

Looks like the installed driver is not correct. Steps to fix:

Delete the device from Device Manager.
Rescan for hardware changes.
"Your Device" will show up with "Unknown driver" status.
Click on "Update Driver" and go to android sdk path and there select /extras/google/usb_driver
Device Manager will find the driver and warn you about installing it. Select "Yes."

This time the device got installed properly.Thanks

Abdulrehman
  • 61
  • 1
  • 3
-1

After installing many drivers and did what have been suggested with platform-tools, i finally solved my problem by symply activate Debuging/Debogage Mode on my device.

So you can check that.