adb common operation commands

Introduction to adb:
  adb, the Android Debug Bridge. Interact with android through this tool

adb command format:

  adb [-d|-e|-s <serialNumber>] <command> 

  Items in square brackets are not required. For example: adb -s emulator-5554 install xxxxxx.apk follow the xxxx app
  -d: Perform naming only for real Android phones connected to the pc. This parameter does not allow the PC side to connect multiple devices
  -e: Similar to -d, perform naming only for an emulated Android phone connected to the PC. This parameter does not allow the PC side to connect multiple devices
  -s: Specify the device through the device serial number to execute the command


Common commands:

Check the adb version: adb version is usually also used to verify whether the adb installation was successful

View connected devices and emulators: adb devices

Install the software: adb install xxx.apk xxx to specify the installed apk path
  Common parameters: -s install to sdk, for example: adb -s install xxx.apk
       -r keep data and cache files, reinstall apk

Uninstall: adb uninstall xxx.apk to uninstall directly
   adb -k uninstall xxx.apk uninstall but keep user's data

Copy files: Copy from pc to phone: adb push [file location on pc] [path to save to phone]
                    From mobile phone to pc: adb push [the location where the mobile phone stores the file] [the path where the file is stored to the pc]

List all the package names of the system: adb shell pm list packages
List all registrations in the system: adb shell pm list packages -s
List third-party application package names except the system's own programs: adb shell pm list packages -3

Pipeline command: | grep is basically the same as in linux

Clear the application's cache and data: adb shell pm clear [package name]

View log: adb logcat

Check the android system version: adb shell getprop ro.build.version.release

Check screen resolution: adb shell wm size

Start adb server: adb start-server
停止adb server:adb kill-server

Reboot: adb reboot

Check if the device is rooted: adb shell  
           his
  $ means no root, # means already root

View resource usage: adb shell top

Simulate key input:
  格式:adb shell input keyevent [keycode]
  adb shell input keyevent 3 Press the home button
  adb shell input keyevent 4 press the return key
  keycode and corresponding key:
  

keycode

button

3

HOME

4

return

5

open dial

6

hang up the phone

24

increase volume

25

lower the volume

26

Power button

27

Photograph

64

Open browser

82

menu

85

play / pause

86

Stop play

87

play next track

88

play previous track

126

Resume playback

127

Pause playback

164

mute

176

Open system settings

207

Open contacts

208

Open Calendar

209

turn on music

210

open calculator

220

Decrease screen brightness

221

Increase screen brightness

223

system hibernation

224

light up the screen

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325026875&siteId=291194637