This article is a mirror article of machine translation, please click here to jump to the original article.

View: 9916|Reply: 1

adb common operation commands are explained in detail and complete

[Copy link]
Posted on 1/7/2018 9:40:51 PM | | | |

Speaking of ADB, everyone should be familiar with it, that is, Android Debug Bridge, Android Debug Bridge, as Android developers, proficient in using ADB commands will greatly improve our development efficiency, ADB commands are numerous, today I will summarize some of the ADB commands I commonly use in development.

Check the version
ADB installation is not much to say here, enter the following command with the following prompt to prove that your environment is OK, otherwise you can search online to solve it.

$ adb version




Android Debug Bridge version 1.0.36
Revision 8f855a3d9b35-android

View connected devices
Enter the following command to query the connected devices and emulators:

$ adb devices

List of devices attached
02ae0c1021089daf       device

Install an apk and execute the following command:
adb install <apkfile>

For example: adb install demo.apk
If it is not the current directory, it should be followed by the path name:

adb install /Users/storm/temp/demo.apk
Keep the data and cache files, reinstall the apk:

adb install -r demo.apk
Install APK to SD Card:

adb install -s demo.apk
Uninstall

Direct Uninstall:
adb uninstall <package>

For example: adb uninstall com.stormzhang.demo
Uninstall the app but keep the data and cache files:

adb uninstall -k com.stormzhang.demo

Start/stop the Server
Generally speaking, the following two commands are basically not used, because as long as the device is connected correctly, the adb server will be automatically started, but you also need to know these two commands:

Start adb server:
adb start-server

Stop adb server:
adb kill-server

List the package names of all apps installed on your phone:
adb shell pm list packages

List all package names for system applications:
adb shell pm list packages -s

List the third-party app package names other than the system app:
adb shell pm list packages -3

Use grep to filter:
adb shell pm list packages | grep qq

Clear app data and cache
Sometimes we need to clear data and cache in our tests, so we need to use the following command:

adb shell pm clear <packagename>

For example: adb shell pm clear com.stormzhang.demo

Launch the app
If we want to launch the app via adb
adb shell am start -n com.stormzhang.demo/.ui. SplashActivity

Force stop the application
Sometimes the app gets stuck and needs to be forced to stop, run the following command:

adb shell am force-stop <packagename>

For example: adb shell am force-stop cn.androidstar.demo

View logs
adb logcat

Restart
adb reboot

Get the serial number
$adb get-serialno

02ae0c1021089daf

Get the MAC address
$adb shell  cat /sys/class/net/wlan0/address

bc:f5:ac:f9:f7:c8

Check the device model
$adb shell getprop ro.product.model

Nexus 5

Check your Android version
$adb shell getprop ro.build.version.release

7.0.1

Check the screen resolution
$adb shell wm size

Physical size: 1080×1920

Check the screen density
$adb shell wm density

Physical density: 480
There are too many commands about ADB, just a few of my most commonly used commands, more commands can be found here:

https://github.com/mzlogin/awesome-adb




Previous:Use adb devices to report error:device offline
Next:WinRAR v5.50 Chinese Simplified Registered No Ads No Modification Original (64-bit/32-bit)
Posted on 1/8/2018 9:41:06 AM |
https://developer.android.com/studio/command-line/adb.html  官方文档链接
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com