19

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
  • 677
  • 1
  • 7
  • 26

7 Answers7

20

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,976
  • 6
  • 34
  • 57
12

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
  • 17,235
  • 8
  • 110
  • 131
6

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,411
  • 13
  • 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
4

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

1
  • For Connect wireless Android Device then follow this simple steps:

    Step 1:

    Attach Android Mobile Device with Cable.

    and make sure mobile and computer must be in Same Network.

    Step 2:

    Open Android Studio and open TERMINAL phase in it. (which is located at left bottom).

    enter image description here

    Step 3:

    Provide path of SDK location.

      Ex:   C:\Users\Admin\AppData\Local\Android\Sdk\platform-tools>
    

    Step 4:

    Provide ADB Connection command:

     -->  adb tcpip 5555
    
       ex: C:\Users\Admin\AppData\Local\Android\Sdk\platform-tools> adb tcpip 5555 [Press Enter Button]
    

    if all aboves step is properly executed then you got Output like:

    enter image description here

    Step 5:

    Here, got your mobile IP address.

    (we got this if mobile device connected via WIFI and make sure computer connected same WIFI )

    and at last make device connection wireless so put this command:

     -->  adb connect 192.168.1.5
    
    ex: C:\Users\Admin\AppData\Local\Android\Sdk\platform-tools> adb connect 192.168.1.5 [Press Enter Button]
    

    and the final ouput:

    connected to 192.168.1.5:5555
    

    ☻♥ Done Keep Code

0

if you are using windows 10 or 11

Search Environment Variables

You will System property dialog

  1. Select Environment Variables describe in Step 1 Environment Variables Screenshot

  2. Now Select Path describe in Step 2 Path Screenshot

  3. Edit this edit screenshot

  4. Click new and add address %USERPROFILE%\AppData\Local\Android\Sdk\platform-tools to your adb executable file copy past address

Umair Khalid
  • 2,259
  • 1
  • 21
  • 28
0

I also faced this problem

I set global environment variable with platform-tools and then adb commands working in cmd but not in android studio terminal then I set the environment variable for android studio also with the following path

FileSettingToolsTerminal and now here set Environment variables in Project Settings by click on Right side icon in Environment variable edit text box. Click on + icon and add Name Path followed with adb path with platform-tools path in values eg.