Using adb for Debugging
Introduction
ADB, which stands for Android Debug Bridge, is a command-line tool that allows you to communicate with an Android device or emulator from your computer. It provides a bridge between your development machine and the Android device.
To use ADB, you need to have the Android SDK (Software Development Kit) installed on your computer. The ADB executable is located in the platform-tools directory of the SDK. You can run ADB commands from a terminal or command prompt window.
Here's an example of how to use ADB to install an APK file onto an Android device:
adb install path/to/your/app.apkUseful Commands
- List all connected devices
adb devices -l- Pair with a device
Make sure developer options are enabled on the device. Allow usb or wireless debugging. Then use pair with paring code, and use the given ip, port and pairing code to pair with the device.
adb pair <ip>:<port> <pairing_code>- Open a shell on the device
If only one device is connected, you can open a shell on the device using the following command.
adb shellThe adb shell uses toybox to provide a set of common linux commands like ls, mkdir etc. Very similar to cgiwin on windows.
- Switch shell user to specific App
You can use the run-as command to switch the shell user to a specific app. This allows you to access the app's files and databases.
adb shell
$ run-as <package_name>