Using the adb command

Run a shell on a device over USB:

adb usb
adb shell

Run a shell on a device over TCP/IP:

Prior to Android 11, it's necessary to tell Android to listen for a connection using adb over USB first:

adb usb
adb tcpip 5555
adb connect hostname:5555
adb shell

I you have multiple devices connected via USB or via USB and TCP/IP, it's necessary to select the device to perform adb comments against:

adb devices

Use the device name in an adb command:

adb -s $(adb devices|grep APPC|cut -f1) shell


adb connect hostname:5555

Install an app:

adb install app.apk

Using the shell

Kill an app:

am force-stop packagename

List available packages and apks:

pm list packages -f

Get package (apks) version:

dumpsys package packagename | grep version

Uninstall an app:

pm uninstall package

It's possible the app is "locked", to remove it from the home screen:

pm uninstall [-k] --user 0 package

Technically it's still there, so we can reinstall it:

cmd package install-existing packagename

Reinstall it:

cmd package install-existing com.velocity

Send home button command:

am start -a android.intent.action.MAIN -c android.intent.category.HOME

Send Keycode:

input keyevent 82 #HOME
input keyevent 4 #BACK

See: for more codes.

Start a different launcher:

am start -a android.intent.action.MAIN

Run an APK

am start -n

Get a list of processes running:

ps -A

Authorize ADB Connections on Device

Consumer devices, such as smartphones and tablets, have more security than commerical devices. This requires performing a "secret" series of interactions in the settings app. You'll need to do some research to find the method to enable connection over USB and to enable "developer mode". After performing this sequence, a menu item to enable connection over USB or developer mode will appear. It's likely you will also need to enable USB connection in "MTP" mode.

Removing a Locked APK

An application may be installed from the factory. Uninstalling it is possible using pm uninstall --user 0 package, however to actually remove the .apk requires removing it from the filesystem. This can be accomplished by re-mounting the filesystem in rw mode, then removing the .apk. It may be necessary to reboot the device because the file is technically "unlinked" so is it's running it will still be running:

pm uninstall --user 0 package
mount -o remount,rw /oem
rm -fr /oem/bundled_persist-app/directory

Maybe you have a new version to install, just use the regular adb install app.apk command, it will now succeed.

Installing a Signed .aab

Normally, sideloading is done using debug build that generates an unsigned APK. However, a React Native using the Expo Updates module for OTA updates requires a release build. Submitting to Google Play requires a signed binary in .aab format. So, testing the binary requires some special care. This can be done using bundletool which is not part of the Android SDK, you'll need to obtain it.

Unpack it:

bundletool build-apks --bundle=./app-release.aab --output=./app-release.apks --ks=/Users/joeb/Desktop/RapidID/dist/android/upload-keystore.jks --ks-key-alias=upload

Then install it:

bundletool install-apks --apks=./app-release.apks

This may fail with this message:

The APKs have been extracted in the directory: /var/folders/0s/t3q2nk696bs11_dfhwq8k2k8378fw_/T/17852975301973829303
10:42:45 E/SplitApkInstallerBase: Failed to commit install session 1454063032 with command cmd package install-commit 1454063032. Error: INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package signatures do not match previously installed version; ignoring!
[BT:1.8.1] Error: Installation of the app failed.

Use this procedure to fully remove the previously installed app:

adb reboot
adb usb
adb shell
pm uninstall
bundletool install-apks --apks=./app-release.apks

The installation should succeed.