ADB is a powerful tool, it is abbreviation of Android Debug Bridge. It is located in
C:\Users\Jerry\AppData\Local\Android\sdk\platform-tools. It provide a lot of useful sub commands for android developers to operate between android physical or virtual device and computer. It can be used to copy files, install app or execute Linux commands in android OS directly. This article will show you how to use it in detail.
ADB Commands Examples
1. List current running android devices.
- First you need to Enable USB debugging mode in your physical android device. You can click here to learn how to do this if you do not know.
- Connect it with PC using a USB line.
- Open dos window, and go to
- Type adb devices, click enter key.
- You can see there is a device listed in the console, it is just the connected physical phone.
- Launch Android Studio, click AVD manager icon in top tool bar.
- It will list all exist android virtual devices in a window as below.
- Click green button to launch an AVD.
- After the virtual device startup. Run adb devices command in dos window, you can see that both the physical device and the virtual device are listed in the window.
2. Copy Files Between Computer And Physical Or Virtual Device.
With adb command, copy files between devices and computer is very easy. By default, adb command always copy files to the currently running device, but if there has more than one devices connected, when you run below command, it will prompt an error message like adb: error: failed to get feature set: more than one device/emulator. So you should only has one device connected with PC.
- adb push c:\windows-version.txt /sdcard/ : This will copy file c:\windows-version.txt to current connected device /sdcard/ directory.
- Now you can check the file in your device to see whether it is there or not.
- You may encounter error message during this process such as “This adb server’s $ADB_VENDOR_KEYS is not set“, just do as the after message suggests “Try ‘adb kill-server’ if that seems wrong. Otherwise check for a confirmation dialog on your device.” can resolve all the problems.
- adb pull /sdcard/roam.txt C:\WorkSpace : This command will pull files from android device to current PC C:\WorkSpace directory.
3. Open Shell Window In Android Device.
The kernel of android platform is Linux-based, and sometimes developers want to open shell window of android platform directly. This allows you to perform some common Linux commands in shell window, such as ls, mkdir, rm, etc. Below commands can achieve this.
- adb shell : This command will let you login to the device as a common user. When the shell opened, we can run cd /sdcard/, ls -l to see the file we just copied.
4. Install or Uninstall APK File.
- adb install [-r -s] apk_file : This command will install apk_file. -r means reinstall this apk, -s means install apk in sd card.
- adb uninstall [-k] package : This command will uninstall apk package. -k means delete the app only but reserve app related settings data and cache.
For more adb command prarmeters, you can run adb -help to get help list of adb command. Or you can click here go to adb online help documents.