12

I tried to run an ADB command in the Android Studio terminal. However I got the following error:

adb is not recognized as an internal or external command

First I turned on ADB integration under Tools > Android menu. Then I tried adding the platform-tools folder to a Path variable under Settings > Appearance & Behavior > Path Variables to no success. (I restarted AS after the change as you would a shell.)

I know an easy fix would be to change my OS path variable, but I would like to avoid doing that. So the question becomes: is there any way to get Android Studio to recognize the command in it's terminal via the settings?

Note and opinion: This happens out of a fresh install of 3.0.1. It seems a little silly to me if the software installs the SDK & tools that it would not have the commands working out of the box in the terminal.

Matthew Cordaro
  • 567
  • 1
  • 5
  • 25

4 Answers4

14

Option 1

• Create a new file, copy paste these 2 lines:

PATH %PATH%;C:\Users\Example\AppData\Local\Android\Sdk\platform-tools
cmd /k "cls"

The path to the adb.exe is just an example. You have to find the correct path first, and use that instead of C:\Users\Example\AppData\Local\Android\Sdk\platform-tools.

• Save the file with .bat extension, e.g. cmdWithAutoUpdatedTempPath.bat.
• Move the file where you want, e.g. C:\Users\Example\AppData\Local\Android.
• In Android Studio, go to FileSettings...ToolsTerminal and set the Shell path to C:\Users\Example\AppData\Local\Android\cmdWithAutoUpdatedTempPath.bat

The name of the file and the path to it is just an example. You have to use the values from the previous two steps, instead of C:\Users\Example\AppData\Local\Android\cmdWithAutoUpdatedTempPath.bat.

Option 2

In Android Studio, go to FileSettings...ToolsTerminal and set the Start directory to C:\Users\Example\AppData\Local\Android\Sdk\platform-tools

The path to the adb.exe is just an example. You have to find the correct path first, and use that instead of C:\Users\Example\AppData\Local\Android\Sdk\platform-tools.

Option 3

Update the path variable by using this command in the terminal, each time a new session is created:
PATH %PATH%;C:\Users\Example\AppData\Local\Android\Sdk\platform-tools

The path to the adb.exe is just an example. You have to find the correct path first, and use that instead of C:\Users\Example\AppData\Local\Android\Sdk\platform-tools.

Tamás Bolvári
  • 2,530
  • 3
  • 28
  • 49
6

The adb tool is located at C:\Users\<YOUR PC USER NAME>\AppData\Local\Android\Sdk\platform-tools on a windows system to access adb from anywhere (android studio,vscode,cmd etc) you need to add this path to the environment variable of your system. for this

  1. search environment variables
  2. go to user variables section and edit path
  3. add new path under key PATH and paste the above path

reopen the application (android studio/cmd/vscode) where you want to access adb, and try typing adb in the cmd ,you will have access to all the adb features.

Mahesh Jamdade
  • 6,758
  • 2
  • 52
  • 64
5

on windows:

If you have installed the software in its default folder, please follow the instructions below:

type:

cd C:\Users\<YOUR PC USER NAME>\AppData\Local\Android\Sdk\platform-tools

YOUR PC USER NAME - is your pc user name (without <> )

after that, please connect device and try adb by typing:

adb devices
Guy4444
  • 1,345
  • 11
  • 15
  • This doesn't answer the question: "is there any way to get Android Studio to recognize the command in it's terminal **via the settings**". – Tamás Bolvári Feb 09 '19 at 11:52
1

If you are using Windows 10, then go to Environmental Variables, Click on New

A new Window will open which will have two fields

  • Variable Name
  • Variable Value

Variable Name: Path

Variable Value: C:\Users<Your PC name>\AppData\Local\Android\Sdk\platform-tools

Hit on Ok then Restart Android Studio