ADB Commands for debugging android devices
Using ADB with cable
You need to install ADB first. Once you have installed ADB you can continue with the commands listed here.
Prior to sending an ADB command, check if the device is available.
adb devices
If the device is correctly plugged in the device ID will be displayed.
Using Wifi
If you plan to use ADB over Wifi, first plug the device using a cable. Then setup the ADB port you will be using (0 - 65535)
adb tcpip 5000
Get the IP address of the device on the common Wifi access point where both devices are connected. Run the following command.
adb connect <IP address>:5000
Now your device will be connected with ADB over Wifi and you can continue to use the device.
Access multiple devices
If you have multiple devices connected to the local machine you can select which device you need to run the commands on with the following command.
Get the device ID with command adb device as above.
Then run:
adb -s <DEVICE ID> shell <commands>
Install an APK file
Open a terminal and run the following command.
adb install -r <path_to_apk_file>
#[-r for replacing old app if version is mismatched]
Remove an installed app
To remove an app you need to know the package name of the app. If you don't know the package name but you know part of the app's name, you can try the following way to find the package name.
adb shell pm list packages | grep <keyword>
Let's say we need to remove facebook app.
adb uninstall com.facebook.katana
Force stop an installed app
To force stop an app, run:
adb shell am force-stop com.facebook.katana