Android adb command line cheatsheet
To use the adb command, make sure you enabled the USB debugging on your device, an emulator is usually enabled by default. The following adb command examples will use this package name for demonstration: com.example.myapp
Show connected devices and pick a device and shell into it. In this case, 7f1c864e is the device id.
adb devices adb -s 7f1c864e shell
Connect to a device wirelessly by ip address.
adb connect 192.168.56.101:5555
Install an app from an apk file on your computer. Replace /Users/dev/android_studio_projects/myapp.apk with your actual apk path on your computer.
adb install /Users/dev/android_studio_projects/myapp.apk
Uninstall an app, the second and the thrid line below are for when you have multple devices connected to your computer, it uninstalls the app on device specified by the device id or network address.
adb uninstall com.example.myapp adb -s 965b8c37 uninstall com.example.myapp adb -s 192.168.56.101:5555 uninstall com.example.myapp
Find the package name of an app by name. Replace app_name with the actual name of the app, a portion of the app name is enough, no spaces.
adb shell pm list package | grep app_name
Find the apk path of an app. Replace com.example.myapp with your own app package name.
adb shell pm path com.example.myapp
Extract the apk from the device to your computer. Replace /data/app/com.example.myapp.apk with your own apk path.
adb pull /data/app/com.example.myapp.apk ./
Copy a file from your computer to the device.
adb push path/to/local/file /sdcard/foo.txt
Usually, this is root folder of your app, replace com.example.myapp with your own package name
Search within Codexpedia
Search the entire web