For our QA team we need to provide an Android emulator without Android Studio.To do this I used the line tools command provided by Google.
I made this folder tree
kit-emulator
-android-sdk
-avd
in the android-sdk subfolder I put the line tools command folder and from this folder using the sdkmanager I download the sdk with this command
sdkmanager --sdk_root=C:\Users\EBERTGU\Desktop\kit-emulator\android-sdk platform-tools emulator platforms;android-30 system-images;android-30;google_apis;x86_64
The download goes smoothly.
The avd folder is designed to accommodate the newly created emulator. For that I use the avdmanager of command line tools with the following command
avdmanager create avd -n "a350" -k "system-images;android-30;google_apis;x86_64" -p "C:\Users\EBERTGU\Desktop\kit-emulator\avd\a350" -f -d "pixel_4_xl"
The emulator is created in the a350 folder contained in the avd folder. You may be wondering what's wrong then. It's s the launch of the emulator.
When I start the emulator with the command emulator #350 I have this error
PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
Error which is explained by itself. So I set my environment variable ANDROID_SDK_ROOT to C:\Users\EBERTGU\Desktop\kit-emulator\android-sdk
I restart the commande line prompt and start again to start the emulator this time I got this error
PANIC: Broken AVD system path. Check your ANDROID_SDK_ROOT value [C:\Users\EBERTGU\Desktop\kit-emulator\android-sdk]!
Now I don't understand why it doesn't work. I searched and opened the emulator ini file inside I found the line
image.sysdir.1=android-sdk\system-images\android-30\google_apis\x86_64\
In despair I changed it to
image.sysdir.1=C:\Users\EBERTGU\Desktop\kit-emulator\android-sdk\system-images\android-30\google_apis\x86_64\
And when I try to start the emulator with the modified image.sysdir.1 line it works !
Anyone have an explanation of why launching doesn't work with base value for image.sysdir.1 and environment variable?
Thank you a lot
Have a nice day
Shindra Guillaume
I found the solution, it was the generation of the emulator from the avdmanager in the bin folder of command tools lines. Just put the files at the root of command tools lines in a subfolder and the system image is properly configured to match that of the root SDK
I m new to the android. i want to do "enable backup with the following command from your SDK tools/ path: adb shell bmgr enable true"
plzz help me how to do this.
I have tried it in cmd bt it is giving me this error
C:\Program Files\Android\Android-sdk\tools>adb shell
'adb' is not recognized as an internal or external command,
operable program or batch file
//you can fine one adb_has_moved.txt in your tools folder
The adb tool has moved to platform-tools/
If you don't see this directory in your SDK,
launch the SDK and AVD Manager (execute the android tool)
and install "Android SDK Platform-tools"
Please also update your PATH environment variable to
include the platform-tools/ directory, so you can
execute adb from any location.
how to set adb path in windows:
I'm testing Android application, and I want to run Robotium test from Terminal on Mac. As I've read I use adb shell am instrument -w com.test.test1/android.test.InstrumentationTestRunner
Terminal says "-bash: adb: command not found".
Probably, I don't see something obvious, but I'm really just studying. What am I missing?
It seems like you don't have your Environment Variables set properly. You need to cd into the directory of your android sdk and then go to platform-tools folder. Once you are in there you will be able to use adb.
here is more information (Goto the part where it talks about environment variables in "Exploring the SDK section"
On Linux, edit your ~/.bash_profile or ~/.bashrc file. Look for a line that sets the PATH environment variable and add the full path to the tools/ and platform-tools/ directories to it. If you don't see a line setting the path, you can add one:
export PATH=${PATH}:/tools:/platform-tools
On a Mac OS X, look in your home directory for .bash_profile and proceed as for Linux. You can create the .bash_profile if you don't already have one.
When launching DDMS from the command line in Lion (10.7.3) I get the following error:
E/adb: Failed to get the adb version: Cannot run program "/Users/stevieo/android-sdk-macosx/tools/adb": error=2, No such file or directory
This makes sense to me because adb is actually in: /Users/stevieo/android-sdks/platform-tools
How can I modify this path so that ddms will launch on my system?
I have looked into the ddms file itself, but cannot decipher its intent.
One note, I do NOT have this issue on Snow Leopard (10.6.8)....
TIA for any thoughts or assistance.
Regards,
Steve O'Sullivan
If you look into your tools directory where you launched ddms, you will see the adb_has_moved.txt which says:
The adb tool has moved to platform-tools/
If you don't see this directory in your SDK,
launch the SDK and AVD Manager (execute the android tool)
and install "Android SDK Platform-tools"
Please also update your PATH environment variable to
include the platform-tools/ directory, so you can
execute adb from any location.
To solve this, I would change your ~/.bash_profile to have a line like:
# --- add Android platform-tools directory
PATH=~/android-sdks/platform-tools:$PATH
export PATH
Make sure to open up a new Terminal window so it will reload ~/.bash_profile
Note that a possible reason why it is working on your 10.6.8 installation is that you may have an older version of the Android SDK, where adb was in still in the tools directory.
If you are trying from eclipse,
Please make sure to create a adb link in /usr/bin/ directory which should solve the problem:
Ex: ln -s /Users//android-sdks/platform-tools/adb /usr/bin/adb
Note: logging as sudo/root may be required
I have installed Android SDK and Eclipse on my Mac system. I am able to program using Eclipse and have created few sample applications. But I am still not able to access adb through the terminal window. I have tried following command in terminal:
$ pwd
/Users/espireinfolabs/Desktop/soft/android-sdk-mac_x86/platform-tools
$ ls
NOTICE.txt dexdump llvm-rs-cc-2
aapt dx llvm-rs-cc.txt
adb lib source.properties
aidl llvm-rs-cc
$ adb --help
-bash: adb: command not found
I have also added the ls output so that you know in which window I am.
The problem is: adb is not in your PATH. This is where the shell looks for executables. You can check your current PATH with echo $PATH.
Bash will first try to look for a binary called adb in your Path, and not in the current directory. Therefore, if you are currently in the platform-tools directory, just call
./adb --help
The dot is your current directory, and this tells Bash to use adb from there.
But actually, you should add platform-tools to your PATH, as well as some other tools that the Android SDK comes with. This is how you do it:
Find out where you installed the Android SDK. This might be (where $HOME is your user's home directory) one of the following (or verify via Configure > SDK Manager in the Android Studio startup screen):
Linux: $HOME/Android/Sdk
macOS: $HOME/Library/Android/sdk
Find out which shell profile to edit, depending on which file is used:
Linux: typically $HOME/.bashrc
macOS: typically $HOME/.bash_profile
With Zsh: $HOME/.zshrc
Open the shell profile from step two, and at the bottom of the file, add the following lines. Make sure to replace the path with the one where you installed platform-tools if it differs:
export ANDROID_HOME="$HOME/Android/Sdk"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
Save the profile file, then, re-start the terminal or run source ~/.bashrc (or whatever you just modified).
Note that setting ANDROID_HOME is required for some third party frameworks, so it does not hurt to add it.
For zsh users. Add alias adb='/Users/$USER/Library/Android/sdk/platform-tools/adb' to .zshrc file.
Then run source ~/.zshrc command
run command in terminal nano $HOME/.zshrc
Must include next lines:
export PATH=$PATH:~/Library/Android/sdk/platform-tools
export ANDROID_HOME=~/Library/Android/sdk
export PATH="$HOME/.bin:$PATH"
export PATH="~/Library/Android/sdk/platform-tools":$PATH
Press Ctrl + X to save file in editor,Enter Yes or No and hit Enter key
Run source ~/.zshrc
Check adb in terminal, run adb
In addition to slhck, this is what worked for me (mac).
To check where your sdk is located.
Open Android studio and go to:
File -> Project Structure -> Sdk location
Copy the path.
Create the hidden .bash_profile in your home.
(open it with vim, or open -e) with the following:
export PATH=/Users/<Your session name>/Library/Android/sdk/platform-tools:/Users/<Your session name>/Library/Android/sdk/tools:$PATH
Then simply use this in your terminal: . ~/.bash_profile
SO post on how to find adb devices
Quick Answer
Pasting this command in terminal solves the issue in most cases:
** For Current Terminal Session:
(in macOS) export PATH="~/Library/Android/sdk/platform-tools":$PATH
(in Windows) i will update asap
** Permanently:
(in macOS) edit the ~/.bash_profile using vi ~/.bash_profile and add this line to it: export PATH="~/Library/Android/sdk/platform-tools":$PATH
However, if not, continue reading.
Detailed Answer
Android Debug Bridge, or adb for short, is usually located in Platform Tools and comes with
Android SDK, You simply need to add its location to system path. So system knows about it, and can use it if necessary.
Find ADB's Location
Path to this folder varies by installation scenario, but common ones are:
If you have installed Android Studio, path to ADB would be: (Most Common)
(in macOS) ~/Library/Android/sdk/platform-tools
(in Windows) i will update asap
If you have installed Android Studio somewhere else, determine its location by going to:
(in macOS) Android Studio > Preferences > Appearance And Behavior > System Settings > Android SDK and pay attention to the box that says: Android SDK Location
(in Windows) i will update asap
However Android SDK could be Installed without Android studio, in this case your path might be different, and depends on your installation.
Add it to System Path
When you have determined ADB's location, add it to system, follow this syntax and type it in terminal:
(in macOS)
export PATH="your/path/to/adb/here":$PATH
for example: export PATH="~/Library/Android/sdk/platform-tools":$PATH
I don't know how did you install the android SDK. But in Mac OS, what really worked for me is to reinstall it using brew. All problems solved in a row.
brew install --cask android-sdk
Later on:
android update sdk --no-ui --filter 'platform-tools'
Like a charm
This is how it worked for me
first I find my platform-tools than I was using zshrc instead of bash_profile so I run this command first
echo 'export PATH=${PATH}:$HOME/Library/Android/sdk/platform-tools/' >> ~/.zshrc
next refresh terminal
source ~/.zshrc
Check if it worked
adb devices
result of this command must be something similar to this if so then it worked.
List of devices attached
emulator-5554 device
For me, I ran into this issue after switching over from bash to zsh so I could get my console to look all awesome fantastic-ish with Hyper and the snazzy theme. I was trying to run my react-native application using react-native run-android and running into the op's issue. Adding the following into my ~.zshrc file solved the issue for me:
export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
If you have installed Android Studio on MAC here is how:
nano ~/.zshrc
or
open ~/.zshrc in VScode
Then edit the file
# Android ADB
export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
control + X OR Save file.
Restart Terminal and try
> adb
UPDATE
As #Loren.A mentioned in comment latest version of brew does not support cast. So one can simply use:
brew install android-platform-tools
Simply install adb with brew
brew cask install android-platform-tools
Check if adb is installed
adb devices
If you are using the Mac with the M1 chip add the below export command to the zshrc file using the nano command, if that file is not present the nano command will create it for you so run
nano ~/.zshrc
paste this path in that file without any modification
export PATH="/Users/$USER/Library/Android/sdk/platform-tools":$PATH
hit ctrl-x and then Hit y to save the changes and the hit return Key to close it without renaming the file.
then run
source ~/.zshrc
to refresh the .zshrc file
and then try runnning
adb
it should give you the desired output
If you are using zsh on an OS X, you have to edit the zshrc file.
Use vim or your favorite text editor to open zshrc file:
vim ~/.zshrc
Paste the path to adb in this file:
export PATH="/Users/{$USER}/Library/Android/sdk/platform-tools":$PATH
For Mac OS Catalina or Mojave
Enter command to open nano editor
nano $HOME/.zshrc
Set PATH variable, means append more path as shown here
FLUTTER_HOME="/Users/pankaj/Library/Android/flutter-sdk/flutter/bin"
DART_HOME="/Users/pankaj/Library/Android/flutter-sdk/flutter/bin/cache/dart-sdk/bin"
ANDROID_SDK_HOME="/Users/pankaj/Library/Android/sdk"
ANDROID_ADB_HOME="/Users/pankaj/Library/Android/sdk/platform-tools"
PATH="$PATH:$FLUTTER_HOME"
PATH="$PATH:$DART_HOME"
PATH="$PATH:$ANDROID_SDK_HOME"
PATH="$PATH:$ANDROID_ADB_HOME"
Now press Command + X to save file in editor,Enter Yes or No and hit Enter key.
This worked for me on my MAC - 2020
Go to directory containing adb:
cd ~/Library/Android/sdk/platform-tools/
Run adb command to list all services
./adb shell dumpsys activity services
I couldn't get the stupid path working so I created an alias for abd
alias abd ="~/Library/Android/sdk/platform-tools/adb"
works fine.
For Mac, Android Studio 3.6.1, I added this to .bash_profile
export PATH="~/Library/Android/sdk/platform-tools/platform-tools":$PATH
Or the alternative solution could be
Make sure you already install for android SDK. Usually it is located under
/Users/your-user-name/Library/Android/sdk
If the SDK is there then run this command. ./platform-tools/adb install your-apk-location
From there you can generate the APK file That's the only sample to check if adb
command is there
For some reason when installed Android Studio 3.6.1 the adb file was actually in $ANDROID_HOME/platform-tools/platform-tools. not sure if this is a bug with my installation or what but this fixed it for me.
For Mac Os the default shell has moved on to "zsh" from "bash" as of Mojave and later releases, so for all the Mac users I would suggest go with the creating ".zshrc" file. "adb" runs as it is intended to be. Thanks #slhck for your info.!
Follow steps below
Open bash_profile using open -e .bash_profile
write
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
close bash_profile file
run source .bash_profile
Done run your adb command now !!
In some cases, you may need to run source .bash_profile every time you open cmd to run adb commands
It's working fine..
brew install android-sdk
Later on:
android update sdk --no-ui --filter 'platform-tools'