ADB essentials
With a phone in the device state, a handful of commands cover most of a working day: install an app, remove it, copy files, ask the phone questions and capture its screen. This lesson shows each one, what it prints, and where the same action lives in DroidDeck.
Every command here acts on one device. If you have more than one connected, add -s and the serial, as in lesson 1.
Packages and APKs
Two words first.
- An APK (Android Package) is the file an app is installed from, ending in
.apk. It is a zip archive holding the app's code, images and a manifest that lists what the app is and what it needs. - A package name is the app's unique ID, written like a reversed web address:
com.android.chrome,com.example.notes. The name under the icon is only a label. Every tool, including ADB, uses the package name.
Install and uninstall
Install an APK from your computer:
$ adb install notes-1.4.2.apk
Performing Streamed Install
SuccessUseful options:
| Option | What it does |
|---|---|
-r | Replace an app that is already installed, keeping its data. This is an update. |
-t | Allow a test-only APK, the kind a development build can produce. |
-d | Allow installing an older version over a newer one (a downgrade). |
-g | Grant every runtime permission the app asks for, without the pop-ups. |
When an install fails, the reason is in capitals inside Failure [...]:
$ adb install -r notes-1.4.2.apk
Performing Streamed Install
adb: failed to install notes-1.4.2.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.example.notes signatures do not match previously installed version; …]That one means the installed copy was signed by a different key, for example a store version, and this APK cannot replace it. Lesson 5 explains signatures. Other common reasons are INSTALL_FAILED_VERSION_DOWNGRADE (use -d if you mean it) and INSTALL_FAILED_INSUFFICIENT_STORAGE.
Remove an app by its package name, not its file name:
$ adb uninstall com.example.notes
SuccessUninstalling deletes the app and its data. adb uninstall -k keeps the data and cache folders, but most of the time you want everything gone or nothing touched.
Push and pull files
ADB's words for copying are from the computer's point of view:
push ──────────────►
COMPUTER PHONE
◄────────────── pull$ adb push notes.txt /sdcard/Download/
notes.txt: 1 file pushed, 0 skipped. …
$ adb pull /sdcard/DCIM/Camera/IMG_20261109_101500.jpg .
/sdcard/DCIM/Camera/IMG_20261109_101500.jpg: 1 file pulled, 0 skipped. …The . at the end of pull means "the current folder". Both commands copy whole folders too.
/sdcard is the phone's shared storage, where photos, downloads and documents live. Most of the rest of the phone, such as other apps' private data in /data/data, is closed to ADB on a normal phone. That is deliberate: apps keep their data private from each other and from you.
WARNING
push replaces a file of the same name on the phone without asking, and pull does the same on your computer. Check the destination first.
The shell
Android is built on Linux, so every phone has a command line. adb shell opens it:
$ adb shell
emu64x:/ $ ls /sdcard
Alarms Android DCIM Documents Download Movies Music Pictures …
emu64x:/ $ exitThe $ in the prompt means you are the ordinary shell user, not root. You can also run one command and come straight back:
adb shell ls /sdcard/DownloadThe shell commands worth knowing first:
pm: the package manager
$ adb shell pm list packages -3
package:com.example.notes
package:org.mozilla.firefox
…
$ adb shell pm path com.example.notes
package:/data/app/~~…/com.example.notes-…/base.apkpm list packages lists every app; -3 keeps only the ones a user installed, -s only system apps. Add a word to filter: pm list packages chrome. pm path shows where an app's APK files are, which is how you can copy an app's APK out with adb pull.
getprop: facts about the phone
$ adb shell getprop ro.build.version.release
14
$ adb shell getprop ro.build.version.sdk
34
$ adb shell getprop ro.product.model
Pixel 7These are system properties, settings the system keeps as name and value pairs. release is the Android version people talk about; sdk is the API level, the number developers use. Run getprop with no name to see them all. Your values will differ from these.
input: press buttons and type
adb shell input keyevent 4 # Back
adb shell input keyevent 3 # Home
adb shell input text "hello" # type into the focused field
adb shell input tap 540 1200 # tap at x=540, y=1200 pixelsHandy for repeating the same steps while testing, or for typing a long test value into a phone.
screencap and screenrecord: capture the screen
adb exec-out screencap -p > screen.pngscreencap -p writes a PNG. exec-out passes the bytes straight to your computer, so the > saves the picture there.
adb shell screenrecord /sdcard/demo.mp4
adb pull /sdcard/demo.mp4
adb shell rm /sdcard/demo.mp4screenrecord runs until you press Ctrl + C or it reaches its limit of 180 seconds. Set a shorter limit with --time-limit 30. The video has no sound, and Android records a frame only when the screen changes, so tap and scroll while it runs. The last line tidies up the copy left on the phone.
The same in DroidDeck
Each DroidDeck button runs one of these commands for you on the device in the device picker:
| You want to | Command | DroidDeck |
|---|---|---|
| Install an APK | adb install -r -t | Apps tab › Install APK, or drop the file on the tab |
| Uninstall | adb uninstall | Apps › an app's Actions menu › Uninstall… |
| Copy an app's APK out | pm path, then adb pull | Actions › Extract APK |
| Push files | adb push | Files tab › Push here |
| Pull a file | adb pull | Files › the file's menu › Pull to ~/Downloads |
| Screenshot | adb exec-out screencap -p | Screen tab › Capture |
| Record the screen | adb shell screenrecord --time-limit | Screen › Screen recording › Start |
| Press Back or Home | adb shell input keyevent | Shell tab › Quick actions |
| Any other command | adb shell | The Shell tab's terminal |
The guides: Manage apps, Browse and transfer files, Use the screen tools, Use the shell and quick actions. The full list of commands is in the DroidDeck reference.
When you do not need ADB
To move a few photos or documents between your phone and a computer, you do not need debugging at all. NearShare receives files on Linux from the phone's own Quick Share, over Wi-Fi, with a PIN shown on both screens, and USB debugging can stay off. Use ADB when you need what only ADB can do: install builds, read logs, run commands.
Stay safe
- Shell commands run at once, with no undo.
rmdeletes for good; there is no recycle bin on the phone. Do not paste commands you do not understand, especially from a forum post. - Uninstall deletes the app's data. Copy out anything you need first.
- Install only APKs you trust. An app installed over ADB gets the same powers as one from a store. Lesson 5 shows how to check one.
- Screenshots and recordings capture everything on screen, including notifications and messages. Look before you attach one to a bug report.
Check yourself
Question 1 of 6
Which command copies notes.txt from your computer to the phone's Download folder?
What you learned
adb installandadb uninstalladd and remove apps; uninstall uses the package name and deletes the app's data.pushcopies to the phone,pullcopies from it;/sdcardis the shared storage ADB can reach.adb shellopens the phone's command line:pmfor packages,getpropfor facts,inputfor keys and taps,screencapandscreenrecordfor the screen.- Each DroidDeck button is one of these commands.
Next steps
- Lesson 3: Wireless debugging: the same commands, without the cable
- Manage apps in DroidDeck
- Use the shell and quick actions