Post

Managing apps using adb

1
adb install <path to .apk>

Using adb install we can manually install packages using the command line.

1
adb shell pm list packages

Lists all installed packages - including system packages.

1
adb shell pm list packages -3

List only third party packages.

1
adb shell pm clear <package_name>

Clear the application data without removing the actual application.

1
adb shell dumpsys package <package_name>

List information such as activities and permissions of a package.

1
adb shell am start <package_name>/<activity_name

Starts the activity of the specified package.

1
adb uninstall <package_name>

Uninstalls the specified application.

adb push

To transfer files between our computer and the device, we use the commands adb push and adb pull.

1
adb push <local_file_on_computer> <target_path_on_device>

With adb push we can push a file or a directory from our computer to the device. We have to specify a destination path - a common one is /sdcard/, which is not an external SD-card, but generally mounts to the internal storage of the device.

Example to push test.png from the Desktop to the Download folder of the device:

1
adb push Desktop/test.png /sdcard/Downloads/

adb pull

1
adb pull <file_path_on_device> [<optional_target path_on_the_computer>]

With adb pull we can pull files from the device to the computer. For example, to download the entire Download folder from the device, we can use:

1
adb pull /sdcard/Downloads

This will store Downloads in your current directory.

Note that with adb pull we can only access the files we have access to with adb shell, and so you will find that you can not download a lot of application files this way.

adb logcat

1
adb logcat -v <log_format>

Change the log format - for example using brief to get a more condensed version of the log.

Log Filtering

In some cases there can be lots of log entries which makes it hard to focus on the things that matter. For example if you are only interested in the logs produced by the MainActivity, you can use a log filter for that:

1
adb logcat "MainActivity:V *:S"

Filter format:

  • MainActivity:V ensures that logs from the tag MainActivity with a severity of Verbose and above are logged
  • :S Ensures that all other Tags are ignored (as nothing will log with log-level Silent or above)

Logging severities:

 Log level
VVerbose
DDebug
IInfo
WWarning
EError
FFatal
SSilent

You can find the full documentation for pm here.

THANKS FOR READING ❤️

This post is licensed under CC BY 4.0 by the author.