10 ADB Commands Interview Questions and Answers
Prepare for your Android development interview with this guide on ADB commands, enhancing your debugging and device management skills.
Prepare for your Android development interview with this guide on ADB commands, enhancing your debugging and device management skills.
ADB (Android Debug Bridge) commands are essential tools for developers and testers working with Android devices. These commands facilitate a wide range of tasks, from debugging applications and managing device files to automating workflows and performing system-level operations. Mastery of ADB commands can significantly enhance your efficiency and effectiveness when working with Android environments.
This article offers a curated selection of ADB command questions and answers to help you prepare for technical interviews. By familiarizing yourself with these commands, you will be better equipped to demonstrate your proficiency and problem-solving abilities in an interview setting.
To list all connected devices using ADB, use the command:
adb devices
The output typically looks like this:
List of devices attached emulator-5554 device 0123456789ABCDEF device
Each column represents:
To install an APK on a connected device, use:
adb install path/to/your/app.apk
Replace path/to/your/app.apk
with the actual path to the APK file. Options include:
For example, to reinstall an app and keep its data:
adb install -r path/to/your/app.apk
To pull a file from a device’s internal storage to your computer, use:
adb pull <remote> <local>
<remote>
: Path to the file on the device.<local>
: Path on your computer to save the file.Example:
adb pull /sdcard/Download/example.txt C:/Users/YourUsername/Desktop/example.txt
This pulls example.txt
from the device’s Download
directory to your computer’s Desktop
.
To filter logs by a specific tag, use:
adb logcat -s <TAG>
For example, to filter logs by the tag “MyAppTag”:
adb logcat -s MyAppTag
To record the screen of an Android device, use:
adb shell screenrecord /sdcard/filename.mp4
Options include:
--time-limit <time>
: Maximum recording time in seconds (default is 180 seconds).--size <width>x<height>
: Video resolution (default is the device’s native resolution).--bit-rate <rate>
: Video bit rate in megabits per second (default is 4Mbps).Example with options:
adb shell screenrecord --time-limit 120 --size 1280x720 --bit-rate 8M /sdcard/recording.mp4
To simulate a touch event on the device screen, use:
adb shell input tap <x> <y>
For instance, to simulate a touch at coordinates (100, 200):
adb shell input tap 100 200
To uninstall an app from a connected device, use:
adb uninstall <package_name>
For example, if the package name is com.example.myapp
:
adb uninstall com.example.myapp
Option:
-k
: Keep the app’s data and cache directories after uninstallation.Example:
adb uninstall -k com.example.myapp
To manage device permissions for an app, use:
adb shell pm grant com.example.app android.permission.CAMERA
Here, com.example.app
is the package name, and android.permission.CAMERA
is the permission being granted.
To push a file from your computer to the device’s internal storage, use:
adb push <local-file-path> <remote-file-path>
<local-file-path>
: Path to the file on your computer.<remote-file-path>
: Path on the device where the file will be stored.Example:
adb push /path/to/local/file.txt /sdcard/file.txt
This pushes the file from your computer to the device’s internal storage.
To kill and restart the ADB server, use:
adb kill-server adb start-server
This might be necessary for: