when typing "adb devices" in Powershell, it return a prompt to ask "How do you want to open this file".
However, if I use "adb.exe devices", it works and give me the list of devices.
As I have a lot of scripts written as adb instead of adb.exe, is there a way to fix this?
In cmd, typing adb devices would also work. But the scripts were all PS based. So fixing this in powershell will really helps. Thanks.
As you've confirmed, the problem was an extraneous, empty file literally named adb (without a filename extension) that resided in your C:\WINDOWS\system32 directory.
Since the PATH environment variable (typically) lists C:\WINDOWS\system32 before the directory in which the desired target executable (adb.exe) is located, C:\Program Files (x86)\Intel\Platform\..., PowerShell attempted to execute C:\WINDOWS\system32\adb, which - as an extension-less file - triggered the GUI dialog you saw.
Removing the extraneous C:\WINDOWS\system32\adb file solved your problem.
Get-Command -All adb helped discovered the problem: it listed all forms of a command named adb known to PowerShell, in order of precedence, with information about their type and location; that is, the effective command - the one that is actually invoked - was listed first.
Read on for background information.
As all shells do, if a command uses a mere (file) name (as opposed to a file path), PowerShell looks for executables in the directories listed in the PATH environment variable (accessible as $env:PATH in PowerShell), in order.
That is, if you submit a command line with command name adb, PowerShell - after looking for an internal command by that name first (an alias, function, or cmdlet) - looks for an executable file whose base name is adb, in the directories listed in $env:PATH, and invokes the first one it finds.
On Windows, an executable file is one whose filename extension is listed in the PATHEXT environment variable ($env:PATHEXT); again, the extensions listed there are considered in order. By contrast, on Unix-like platforms it is solely the file mode (the permission bits) that determine whether a file is executable.
However, unlike other shells, PowerShell doesn't just look for executable files in $env:PATH, it considers any file that exactly matches the command name given executable, and in effect passes such a file to the Invoke-Item cmdlet, which triggers the default GUI shell action on the file, equivalent to double-clicking a document in File Explorer on Windows.
This problematic behavior is discussed in this GitHub issue, which proposes that only true executables be considered commands.
I did set up of Android, Java and Eclipse to start up my project but soon after running my emulator a few times I got error like “The connection to adb is down, and a severe error has occured.”
I referred to this question and got answer but while running adb from command prompt I am getting error as "'adb' is not recognized as an internal or external command,operable program or batch file."
How to run this adb commands without admin rights on machine?
but while running adb from command prompt i am getting error as "'adb' is not recognized as an internal or external command,operable program or batch file."
This is usually a path problem.
Linux
This is usually one of two problems on Linux.
First, adb is simply not on path. Its located in <Android SDK>/platform-tools, so platform-tools needs to be on path. To ensure its on path, you want something like this in your login script (.bashrc, .bash_profile, etc). Below is from Mac OS X and .bash_profile:
export JAVA_HOME=`/usr/libexec/java_home`
export ANDROID_NDK_ROOT=/opt/android-ndk-r9c
export ANDROID_SDK_ROOT=/opt/android-sdk-macosx
export PATH="$ANDROID_SDK_ROOT/tools/":"$ANDROID_SDK_ROOT/platform-tools/":"$PATH"
Second, the problem can occur on Linux if its x86_64 and you don't have ia32_libs installed. Tools like adb are 32-bit, so you need to install ia32_libs for the entire 32-bit subsystem for 64-bit Linuxes.
Windows
Windows has a PATH variable, and it can be adjusted per-user. Ensure <Android SDK>/platform-tools is on path in Windows. It would not hurt to ensure <Android SDK>/tools is on path also.
If you add a %PATH% variable, you can copy it from the System's %PATH% first. Then modify your copy.
You getting error like "'adb' is not recognized as an internal or external command,operable program or batch file." has nothing to do with your admin rights.
Follow the steps:
Go to folder location where your 'adb.exe' is located.
copy the path and open cmd prompt and paste your folder location
Example: C:\Users\298xxx>C:\Android\adt-bundle-windows-x86-20131030\adt-bundle-windows-x8
6-20131030\sdk\platform-tools\adb.exe
Run any adb command you want like
C:\Users\298xxx>C:\Android\adt-bundle-windows-x86-20131030\adt-bundle-windows-x86-20131030\sdk\platform-tools
\adb.exe devices
List of devices attached
emulator-5554 device
Problem is that in machine you need to set path of ADB.exe in system properties but you didn't had access as admin which don't allowed you to open/work directly with system related things like install/uninstall/path setting and many more.
Another way to do the same is
press ctrl+alt+del to open task manager
Go to File --> New Task -- > and copy paste the path of you adb.exe (space) devices to check for devices attached to your machine.
I am trying to run google map v2 on emulator, I am following this tutorial.
When I was trying to install required apk file on emulator, I am getting below error.
I tried to solve this using this tutorial.Followed all steps, added the path to paltform-tools to environment path. Also after modifying the PATH variable started a new CommandPrompt window.
But getting the same error. I need to check my google map application on emulator.
Kindly suggest me.
'adb' is not recognized as an internal or external command,
operable program or batch file.
Set the path of adb into System Variables. You can find adb in "ADT Bundle/sdk/platform-tools" Set the path and restart the cmd n then try again.
Or
You can also goto the dir where adb.exe is located and do the same thing if you don't wanna set the PATH.
If you wanna see all the paths, just do
echo %PATH%
From Android Studio 1.3, the ADB location is at:
C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools.
Now add this location to the end of PATH of environment variables. Eg:
;C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools
If you want to use it every time add the path of adb to your system variables:
enter to cmd (command prompt) and write the following:
echo %PATH%
this command will show you what it was before you will add adb path
setx PATH "%PATH%;C:\Program Files\android-sdk-windows\platform-tools"
be careful the path that you want to add if it contains double quote
after you restart your cmd rewrite:
echo %PATH%
you will find that the path is added
PS: if you just want to add the path to cmd just to this session you can use:
set PATH=%PATH%;C:\Program Files\android-sdk-windows\platform-tools
I did this on Windows 7, by going to:
Start > Control Panel > System > Advanced System Settings > Environment Variables...
In this Environment Variables window, in the User variables for (your-username) highlight Path and click Edit...
You then need to append a ; if there isn't already one at the end of the Variable value field, and then append C:\Users\<your-username>\AppData\Local\Android\sdk\platform-tools; to that same field.
Then click the three OK buttons to get out.
If you already have a Command Prompt window open, close it then re-open and the adb devices command should then work.
In Windows 10,
Add User Variable PATH: %USERPROFILE%\AppData\Local\Android\sdk\platform-tools.
Restart cmd (if any open).
adb devices, it should list, if it does, you are all set.
That's it!
On Window, sometimes I feel hard to click through many steps to find platform-tools and open Environment Variables Prompt, so the below steps maybe help
Step 1. Open cmd as Administrator
Step 2. File platform-tools path
cd C:\
dir /s adb.exe
Step 3: Edit Path in Edit Enviroment Variables Prompt
rundll32 sysdm.cpl,EditEnvironmentVariables
more, the command to open environment variables can not remember, so I often make an alias for it (eg: editenv), if you need to work with environment variables multiple time, you can use a permanent doskey to make alias
Step 4: Restart cmd
Add your path into environment variable "PATH" where you installed your sdk with below:
\Sdk\platform-tools
You can in image below for example:
and reopen your command prompt to see changes.
Follow path of you platform tools folder in android setup folder where you will found adb.exe
D:\Software\Android\Android\android-sdk\platform-tools
Check the screenshot for details
If your OS is Windows, then it is very simple.
When you install Android Studio, adb.exe is located in the following folder:
C:\Users\**your-user-name**\AppData\Local\Android\Sdk\platform-tools
Copy the path and paste in your environment variables.
Open your terminal and type: adb it's done!
adb command can be under the new path below-
C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools
for new versions of Android studio.
I found in this location for me.
For environment variable, we have to need to follow some steps.
just open Android studio and press "Tools" on Top navigation bar
tools->SDK Manager
Where you can get SDK location
Open SDK folder -> platform-tools
You will need to set the PATH variable pointing to the directory where adb.exe is to be found. If you are using cmd.exe, this command will help:
set PATH=%PATH%;%USERPROFILE%\appdata\Local\Android\sdk\platform-tools
1st: goto the drive where your eclipse reside and goto sdk and platform tool in my case C:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools
2nd:copy that address for ease of access
3:open command prompt win+r and type cmd hit enter
4:paste the address in cmd and hit enter thats all
In new version PowerShell, after all steps that mentioned before this, please attend:
before
adb
now
.\adb
I recommand you using PowerShell
Set Android Studio Terminal to PowerShell:
Settings > Tools > Terminal > Shell path = pwsh.exe (instead of cmd.exe)
Open Terminal on Android Studio
PowerShell 7.0.1
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/powershell
Type 'help' to get help.
PS >
Test the path for adb.exe
# `pikachu` should be replace your username
PS > test-path "C:\Users\pikachu\AppData\Local\Android\sdk\platform-tools"
True
Open your powershell profile file in your text editor
PS > notepad $profile
add below line, save and exit
# `pikachu` should be replaced with your username
$env:PATH+=";C:\Users\pikachu\AppData\Local\Android\sdk\platform-tools"
re-open Terminal and try adb
PS > adb
Android Debug Bridge version 1.0.41
Version 30.0.1-6435776
Installed as C:\Users\hdformat\AppData\Local\Android\sdk\platform-tools\adb.exe
global options:
-a listen on all network interfaces, not just localhost
-d use USB device (error if multiple devices connected)
-e use TCP/IP device (error if multiple TCP/IP devices available)
-s SERIAL use device with given serial (overrides $ANDROID_SERIAL)
-t ID use device with given transport id
-H name of adb server host [default=localhost]
-P port of adb server [default=5037]
Based on Vamsi Tallapudis earlier answer I came up with this dynamic path:
%LOCALAPPDATA%/Android\sdk\platform-tools
It's using a Windows Environment Variables. I find this solution to be both elegant and easy and would therefor like to share it.
Since I installed version 1.0.41,
I had to use the command "adb version" instead of "adb –version", in Windows 10.
Check and add these below loacations to the path variable:
C:\Users\Sameera\AppData\Local\Android\Sdk\tools
C:\Users\Sameera\AppData\Local\Android\Sdk\platform-tools
C:\Users\Sameera\AppData\Local\Android\Sdk\build-tools
ANDROID_HOME
C:\Users\Sameera\AppData\Local\Android\Sdk
I had same problem when I define PATH below
C:\Program Files (x86)\Java\jre1.8.0_45\bin;C:\dev\sdk\android\platform-tools
and the problem solved when I bring adb root at first.
C:\dev\sdk\android\platform-tools;C:\Program Files (x86)\Java\jre1.8.0_45\bin
In my case it was:
C:\Program Files (x86)\Android\android-sdk\platform-tools
This is where I found it:
C:\Users\<USER>\AppData\Local\Android\sdk\platform-tools
I had to put the complete path into the file explorer. I couldn't just click down to it because the directories are hidden.
I found this path listed in Android studio:
Tools > Android > SDK Manager > SDK Tools
This answer assumes that the PATH has been correctly set as described in the other answers.
If you're on Windows 10 and don't have Admin rights, then right click on the CMD, powershell ... program and select run as administrator. Then try adb [command]
First select drive that is where Android sdk folder is there. Then you Follow the below steps
cd DriveName:/ or Ex : cd c:/ Press 'Enter'
then you will give the path that is adb console path is there in a platform-tools folder
so
cd Root Folder/inner root folder if there/Platform-tools Press 'Enter' then it selects the adb directory.
If you didn't set a path for ADB, you can run .\adb instead of adb at sdk/platformtools.
It seems that Avast antivirus detects adb.exe as a virus and adds it to it chest
For those using macOS, this osxdaily.com article shows several ways to add adb to the $PATH.
Here's the one I prefer:
Add a file named adb to /etc/paths.d/ folder that just contains the path to adb's location: /Users/YourUserName/Library/Android/sdk/platform-tools/
In a Terminal window, sudo vim /etc/paths.d/adb
-> enter the path and save the file.
Close/re-open Terminal in order for it to see the change.
You could just drag the adb.exe on to the command prompt from sdk/platformtools and leave a space and type the command you want: like logcat.
It looks like this for me:
C:\adt-bundle-windows-x86-20130917\adt-bundle-windows-x86-20130917\sdk\platform-tools.exe logcat
and hit enter.
I pulled out a file from the android sdcard using adb and it seems it goes to c:\documents and settings\userName by default. I don't know how it got set to this folder since this is not where adb is installed, but probably has got something to do with the fact that both the workspace and .android folders are located here. How do I change this default location for pull command of adb?
The default directory for adb pull or adb push seems to be the current directory (aka . ).
If you issue a command such as the following, not specifying the target directory
adb pull /boot.txt
the file (provided it exists) will be copied to the current directory.
Windows users:
Take notice of the following: If you are using Windows (Vista or newer), chances are that if the current directory requires elevated privileges to write on, Windows will silently replicate the directory structure of your current directory in a special folder called VirtualStore and will copy your files in it.
The full path for VirtualStore is: %LOCALAPPDATA%\VirtualStore, which most likely will translate into C:\Users\<account_name>\AppData\Local\VirtualStore.
So, in the following scenario,
C:\> cd "C:\Program Files (x86)\MyCustomADBInstallLocation"
C:\Program Files (x86)\MyCustomADBInstallLocation> adb pull /boot.txt
your file boot.txt will end up in this folder
C:\Users\<account_name>\AppData\Local\VirtualStore\Program Files (x86)\MyCustomADBInstallLocation\
you can mention the destination location for adb push/pull, see example:-
adb push a.txt /data/local
adb pull /data/local/a.txt .
. means present directory.
or
adb pull /data/local/a.txt C:\
Hope this helps.
i'm using linux, and noticed that if i opened the terminal as root, its opened # home. when i pull items, it dumps to that repository, meaning to my "home" directory. will try opening terminal in a different folder and running adb pull from there to see if that makes the files dump to the folder terminal is opened in.
I'm having precisely the same issue as this person:
android' is not recognized as an internal or external command
However, I have also set the PATH environment variable (Windows 7) as recommended in the answer to the above post. In particular, I have:
C:\Users\p\AppData\Local\Android\android-sdk\tools
and
C:\Users\p\AppData\Local\Android\android-sdk\platform-tools
In addition, I have set %ANT_HOME%\bin and %JAVA_HOME%\bin. I have checked that the android.bat is indeed in the tools directory pointed to, that the PATHEXT variable contains ".bat", and I have restarted the command prompt. And yet 'android' is not recognized.
Does anyone have an idea what might be the problem? Many thanks in advance!
Find android.bat on your system. On mine (win 8 x64) it's under C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat
Open a command console, and use the 'doskey' command:
doskey android=C:\Users\{username}\AppData\Local\Android\sdk\tools\android.bat $*
This will continue to work in the command console you executed the doskey command in. To make it permanent is more difficult: http://darkforge.blogspot.com/2010/08/permanent-windows-command-line-aliases.html
I do not know what causes the issue with the path variable.
However, the workaround I've used is to move to the "tools" directory and call android from there; I've added "--path " to point to the directory in which the project resides.
Details on how to manage android projects from the command line can be found here:
http://developer.android.com/tools/projects/projects-cmdline.html
You might have installed Cygwin as part of the SDK. I had the same problem "android.bat is not recognized as an internal or external command". So, Uninstall the Cygwin and try again (you might not able to uninstall Cygwin, since a mysterious “permission denied” when deleting the Cygwin files by default). You need to own access to this mysterious Cygwin files by taking ownership:
takeown /r /d y /f cygwin (do this, wherever is your cygwin folder is)
This command takes ownership recursive of the folder, without asking anything and gives Full Access to Everyone recursively in the folder:
icacls cygwin /t /grant Everyone:F
And finally, the command which deletes it all and removes Cygwin:
rmdir /s /q cygwin
Good bye Cygwin! ;-)
Now try again. (This worked for me)
PS: You can always re-install cygwin again. So, nothing wrong giving it a try. Good Luck
**Set the path in windows**
Control Panel\System and Security\System > advance system settings > environment variables
and update the path to include the following:enter code here
<android-root>\android-sdk-windows\tools
Use semicolons to separate paths in case yo have to add more path .