What is the adb
ADB Debug Bridge is a tool in the Android SDK that allows you to directly manage Android emulators or real Android devices (mobile phones).
Main uses of ADB commands
- Running the shell on an Android device (command line)
- Manage mapping ports for emulators or Android devices
- Install and uninstall the application
- Upload and download files between computer and Android device.
Common commands
The specified device
// Display all adb devices that are connected to ADB. // Use the first real device shown in ADB Devices$commandObjective the adb-d $command// Use the first emulator shown in ADB Devices$commandObjective the adb-e $command// Use the devices shown in adb Devices for the specific serialNumber$commandObjective the adb-s <serialNumber> $command
Copy the code
Installation & Uninstallation
Adb install -r ADB uninstall$packageName// Retain data information, but require the newly installed APK to be consistent with its signature adb uninstall-k$packageName
Copy the code
Upload & Download
// Upload files from PC to PC adb push /users/desktop /sdcard/data/ // upload files from PC to PC ADB pull /sdcard/screenshot.png /users/desktopCopy the code
Shell related
Start the
Adb shell am start-d ${appScheme}// Open adb shell start with package${packageName}// Open adb shell am start -n with the Activity${Activity}
Copy the code
remove
// uninstall Adb shell PM uninstall${packageName}Adb shell PM clear${packageName}
Copy the code
dumpsys
Adb shell dumpsys Activity ADB shell dumpsys Activity top adb shell dumpsys cpuinfo Adb shell Dumpsys Power Adb shell Dumpsys PowerCopy the code
Screen capture and recording
// adb shell screencap /sdcard/screen.png // ADB shell Screenrecord-size 720*1280 /sdcard/record.mp4Copy the code
Screen parameters
Adb shell WM density adb shell WM densityCopy the code
System parameters
// System version adb shell getProp ro.build.version.releaseCopy the code
logcat
// Mobile phone locallogExport the adb logcat-d>> ~/Desktop/1.txt // Mobile ANRlogAdb pull /data/anr/ testamp. TXT // Error/Fatal logs adb logcat *:efCopy the code