Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. It is a client-server program that includes three components:
- A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
- A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
- A daemon, which runs as a background process on each emulator or device instance.
Here are 10 ADB commands that you must know:
1. View connected device(s) : Use this to view all connected devices and list their IDs.
adb -s DEVICE_ID
to target a specific device.
2. Install an application :
Use the install command to install an apk, the optional -r argument reinstalls and keeps any data if the application is already installed on the device.
adb install -r APK_FILE
adb install -r ~/application.apk
3. Uninstall an application :
adb uninstall PACKAGE_NAME
adb uninstall com.idigitalorbis.example
4. Entering the device’s shell :
5. Take a screenshot :
adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
6. Power button : This command sends the power button event to turn the device on or off.
adb shell input keyevent 26
7. Unlock screen :
This command sends the event that unlocks the lockscreen on the device. It can be combine with the power button command above to turn on and unlock the device.
adb shell input keyevent 82
adb shell pm list packages -f
adb logcat -c