Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
29 views7 pages

ADB Commands and The Functions

adb commands for the adb.exe in android app building

Uploaded by

otanaagunbiade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views7 pages

ADB Commands and The Functions

adb commands for the adb.exe in android app building

Uploaded by

otanaagunbiade
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

ADB Commands and the Functions.

PS: Always remember to put “./” before the command, e.g. ./adb devices
ADB (Android Debug Bridge) is a versatile command-line tool that allows you to
communicate with an Android device. Below is a list of common commands and
operations that can be carried out using ADB for a mobile device:

### Basic Commands:


1. **Connect to a device:**
- `adb devices` - Lists all connected devices.
- `adb connect <ip_address>` - Connects to a device over Wi-Fi.

2. **Install and Uninstall Apps:**


- `adb install <path_to_apk>` - Installs an APK on the device.
- `adb uninstall <package_name>` - Uninstalls an app from the device.
- `adb install -r <path_to_apk>` - Reinstalls or updates an app.

3. **Transfer Files:**
- `adb push <local_path> <remote_path>` - Copies a file from your computer
to the device.
- `adb pull <remote_path> <local_path>` - Copies a file from the device to
your computer.

4. **Reboot the Device:**


- `adb reboot` - Reboots the device.
- `adb reboot bootloader` - Reboots the device into the bootloader mode.
- `adb reboot recovery` - Reboots the device into recovery mode.

5. **Shell Access:**
- `adb shell` - Starts a remote shell on the device.
- `adb shell <command>` - Runs a command directly in the device's shell.
- `adb shell pm list packages` - Lists all installed packages.
- `adb shell pm uninstall -k --user 0 <package_name>` - Uninstalls system
apps for the current user.
6. **Logcat:**
- `adb logcat` - Displays the log data from the device.
- `adb logcat > log.txt` - Saves log data to a file.

7. **Screen Capture:**
- `adb shell screencap /sdcard/screenshot.png` - Takes a screenshot.
- `adb pull /sdcard/screenshot.png` - Pulls the screenshot to your computer.

8. **Screen Recording:**
- `adb shell screenrecord /sdcard/screenrecord.mp4` - Starts recording the
screen.
- `adb pull /sdcard/screenrecord.mp4` - Pulls the recorded video to your
computer.
- `adb shell screenrecord --time-limit <seconds> /sdcard/screenrecord.mp4` -
Records screen with a time limit.

9. **App Information:**
- `adb shell dumpsys package <package_name>` - Displays detailed
information about a specific app.

10. **Device Information:**


- `adb shell getprop` - Retrieves system properties.
- `adb shell dumpsys` - Provides detailed information about the system.
- `adb shell cat /proc/cpuinfo` - Displays CPU information.
- `adb shell df` - Displays disk usage statistics.

11. **Network Operations:**


- `adb shell ip addr show` - Displays IP addresses.
- `adb shell ifconfig` - Displays network interfaces.
- `adb shell ping <host>` - Pings a host from the device.

12. **Manage Processes:**


- `adb shell ps` - Lists all running processes.
- `adb shell kill <pid>` - Kills a process by its process ID.

13. **Change Device Settings:**


- `adb shell settings get <namespace> <key>` - Gets a system setting.
- `adb shell settings put <namespace> <key> <value>` - Changes a system
setting.
- Example: `adb shell settings put system screen_brightness 200` - Changes
screen brightness.

14. **Wipe Data/Factory Reset:**


- `adb shell wipe data` - Wipes all user data and performs a factory reset.

15. **Simulate User Actions:**


- `adb shell input text <string>` - Inputs text on the device.
- `adb shell input tap <x> <y>` - Simulates a tap at the specified
coordinates.
- `adb shell input swipe <x1> <y1> <x2> <y2> <duration>` - Simulates a
swipe gesture.

16. **Wireless ADB:**


- `adb tcpip 5555` - Enables ADB over Wi-Fi.
- `adb connect <device_ip_address>:5555` - Connects to the device over Wi-
Fi.

17. **Backup and Restore:**


- `adb backup -apk -shared -all -f <backupfile>` - Creates a full backup of the
device.
- `adb restore <backupfile>` - Restores the backup to the device.

18. **Enter Fastboot Mode:**


- `adb reboot bootloader` - Reboots into bootloader (fastboot) mode.
- `fastboot devices` - Lists devices in fastboot mode.
- `fastboot flash <partition> <file>` - Flashes a file to a partition.
19. **Emulator Commands:**
- `adb emu kill` - Kills the emulator.
- `adb emu avd name` - Gets the AVD name of the emulator.

20. **Secure Permissions:**


- `adb shell pm grant <package_name> <permission>` - Grants a specific
permission to an app.
- `adb shell pm revoke <package_name> <permission>` - Revokes a specific
permission from an app.

Certainly! Here are additional ADB commands and operations that you can use
to manage your Android device:

### Advanced Commands:

21. **Manage Partitions:**


- `adb shell mount` - Displays mounted partitions.
- `adb shell umount <partition>` - Unmounts a partition.
- `adb shell mkfs.ext4 /dev/block/<partition>` - Formats a partition with the
ext4 filesystem.

22. **Control Power and Display:**


- `adb shell input keyevent 26` - Toggles the device's power (lock/unlock
screen).
- `adb shell input keyevent 224` - Turns on the screen.
- `adb shell input keyevent 223` - Turns off the screen.
- `adb shell wm size` - Displays the current screen resolution.
- `adb shell wm size <width>x<height>` - Changes the screen resolution.
- `adb shell wm density` - Displays the current screen density (DPI).
- `adb shell wm density <dpi>` - Changes the screen density.

23. **Manage Apps:**


- `adb shell pm clear <package_name>` - Clears all data for a specific app.
- `adb shell pm disable-user <package_name>` - Disables a system app for
the current user.
- `adb shell pm enable <package_name>` - Re-enables a disabled app.
- `adb shell pm hide <package_name>` - Hides an app (Android 9+).
- `adb shell pm unhide <package_name>` - Unhides a hidden app.

24. **Manage Permissions and Security:**


- `adb shell dpm set-device-owner <component>` - Sets a device owner app
(used in enterprise deployments).
- `adb shell pm list permissions -d -g` - Lists all permissions with descriptions
and groups.
- `adb shell appops set <package_name> <operation> <mode>` - Controls
app operations (e.g., location access).

25. **Capture Bug Reports:**


- `adb bugreport <file>` - Generates a bug report and saves it to a file.
- `adb shell dumpsys bugreport` - Provides a detailed bug report directly in
the terminal.

26. **Monitor Network Traffic:**


- `adb shell netstat` - Displays network connections and statistics.
- `adb shell iptables -L` - Displays firewall rules.
- `adb shell tcpdump -i any -p -s 0 -w /sdcard/capture.pcap` - Captures
network packets (requires root).

27. **Manage Battery:**


- `adb shell dumpsys battery` - Displays battery status and details.
- `adb shell dumpsys battery set level <level>` - Sets the battery level (for
testing purposes).
- `adb shell dumpsys battery reset` - Resets battery stats to their real values.

28. **System and Performance Monitoring:**


- `adb shell top` - Displays real-time system resource usage.
- `adb shell vmstat` - Provides system memory statistics.
- `adb shell iostat` - Displays disk I/O statistics.

29. **Simulate Sensors:**


- `adb shell sensorservice` - Lists available sensors.
- `adb shell am broadcast -a com.android.intent.action.MOCK_SENSOR` -
Simulates sensor data (requires a compatible app).

30. **Manage Notifications:**


- `adb shell dumpsys notification` - Displays detailed information about
notifications.
- `adb shell cmd notification list` - Lists active notifications.
- `adb shell cmd notification snooze-package <package_name> <duration>` -
Snoozes notifications from a specific app.

31. **Set Screen and Sound Settings:**


- `adb shell settings put system screen_off_timeout <ms>` - Sets the screen
timeout duration.
- `adb shell settings put system volume_music_speaker <level>` - Sets the
media volume level.

32. **Capture System and App Crashes:**


- `adb logcat -b crash` - Displays only crash logs.

33. **Use Key Events:**


- `adb shell input keyevent <keycode>` - Simulates hardware button presses
(e.g., `adb shell input keyevent 3` simulates pressing the Home button).

34. **Control Clipboard:**


- `adb shell am broadcast -a clipper.set -e text "<text>"` - Sets the clipboard
content.
- `adb shell am broadcast -a clipper.get` - Retrieves the clipboard content.

35. **Force App Stops and Restarts:**


- `adb shell am force-stop <package_name>` - Forces an app to stop.
- `adb shell am start -n <package_name>/<activity_name>` - Starts an app's
activity directly.

36. **Simulate GPS Location:**


- `adb shell am startservice -a
com.google.android.gms.location.ACTION_START -e lat <latitude> -e lon
<longitude>` - Simulates a GPS location.

37. **Simulate Gestures:**


- `adb shell input swipe <x1> <y1> <x2> <y2> <duration>` - Simulates a
swipe gesture.
- `adb shell input tap <x> <y>` - Simulates a tap on the screen.

38. **Manage Multiple Users:**


- `adb shell pm create-user <user_name>` - Creates a new user.
- `adb shell pm remove-user <user_id>` - Removes a user.
- `adb shell am switch-user <user_id>` - Switches to a different user.

39. **Emulator-Specific Commands:**


- `adb emu geo fix <longitude> <latitude>` - Simulates GPS coordinates in
an emulator.
- `adb emu avd snapshot save <snapshot_name>` - Saves an emulator
snapshot.

40. **Development Options:**


- `adb shell settings put global development_settings_enabled 1` - Enables
developer options.
- `adb shell settings put global stay_on_while_plugged_in 1` - Keeps the
screen on while charging.

These commands further enhance the capabilities of ADB, allowing you to


perform in-depth system analysis, simulate various conditions, manage system
settings, and control app behavior, making it an essential tool for Android
developers, testers, and power users.
These commands provide extensive control over your Android device, enabling
you to perform tasks such as debugging, installing apps, managing files, and
configuring settings.

You might also like