Android Common ADB commands

Source: Internet
Author: User

View Original: http://blog.csdn.net/u010818425/article/details/52266593

(i) Basic operation
    • Install the App

      adb install -r xxx.apk //覆盖安装,保留数据和缓存文件adb install -s xxx.apk //安装apk到sd卡adb install -f xxx.apk //安装apk到内部系统内存adb install -d xxx.apk //安装低版本Apkadb install -g xxx.apk //准许Apk manifest中的所有权限
    • Get the installation location

      adb shell pm get-install-location
    • Uninstall app

      adb uninstall <package>adb uninstall -k <package> //卸载app但保留数据和缓存文件
    • Restart your phone

      adb reboot
    • Start ADB service

      adb start-server
    • Close Service

    • Entering the shell environment

      adb shell
(ii) Equipment Information view
    • View the connected device and the serial number of the device

      adb devices
    • View phone CPU architecture (eg. ARMV7) and number of cores

      adb shell cat /proc/cpuinfo
    • View detailed memory information for the system, including kernel conditions

      adb shell cat /proc/meminfo
    • Get Phone disk space

      adb shell df
    • Get the phone system version

      adb shell getprop ro.build.version.release
    • Get Machine MAC Address:

      adb shell  cat /sys/class/net/wlan0/address
    • View WiFi password

      adb shell cat /data/misc/wifi/*.conf
(iii) PM/AM related
    • Clear the app's data

      adb shell pm clear <package>
    • View app Path

      adb shell pm path <package>
    • View package names for all installed apps

      adb shell pm list packages -f
    • View the package name of the app that contains the "Google" field

      adb shell pm list packages google
    • View package names for third-party apps

      adb shell pm list packages -3
    • Start an activity for an app

      adb shell am start -n packagename/packagename.activityname如:adb shell am start -n com.company.appname/ .SplashActivity -es url http://www.baidu.com //-es表示需传递参数,其中url表示参数名,链接表示具体参数值
    • Dial number

      adb shell am start -a android.intent.action.CALL -d tel:10086
    • Open Web site

      adb shell am start -a android.intent.action.VIEW -d http://www.baidu.com
(iv) Process/service View
    • viewing process information

      adb shell ps | grep xxx
    • View the specified process state

      adb shell ps -x [pid]
    • Periodically print out the process run queue, System switchover, CPU time ratio, etc.

      adb shell vmstat
    • Memory usage of each process

      adb shell procrank
    • Kill a Process

      adb shell kill [pid]
    • View Background Services Information

      adb shell service list
(v) Dumpsys series
    • View the dump services supported by the current phone

      adb shell dumpsys -l
    • View package Information Packages information

      adb shell dumpsys packageadb shell dumpsys package packages | grep <package>  //查看某个app资源路径
    • View Memory usage

      adb shell dumpsys meminfo | grep xxxadb shell dumpsys meminfo <pid> // 输出指定pid的内存使用情况adb shell dumpsys meminfo --package <package> // 输出指定包名内存使用情况adb shell top -m 6 //查看内存占用前6的app
    • View top of the stack activity, can be used to get the package name, view the other app's package name

      adb shell dumpsys activity top
    • View rendering time-consuming

      adb shell dumpsys gfxinfo <package> > /sdcard/fps.txt 取出文件:adb pull /sdcard/fps.txt /Users/admin/Downloads/1234.txt
    • View the status of AM

      adb shell dumpsys activity
    • Memory use over time

      adb shell dumpsys procstats
(vi) File operations
    • Move files/Folders

      adb shell mv path/file newpath/file
    • New Folder

      adb shell mkdir path
    • New file

      adb shell touch filename
    • Renaming files/folders

      adb shell rename path/filename newpath/newfilename
    • View File Contents

      adb shell cat file
    • Copy files from your phone to your computer

      adb pull /data/anr/traces.txt /Users/admin/Downloads/1234.txt
    • Send files from your computer to your phone

      adb push foo.txt /sdcard/foo.txt
(vii) Log-related
    • View Logs

      adb logcat | grep xxx
    • Log output to File

      adb logcat -d > ~/Desktop/logcat.txt //保存到桌面,需要android.permission.READ_LOGS
    • Clear the log cache

      adb logcat -c
(eight) Other
    • Connect to the specified IP, usually with Wifidebug

      adb connect <device-ip-address>
    • Run Monkey

      adb shell monkey -v -p <package> 500 // 跑500次
    • Screen Cutting

      adb shell /system/bin/screencap -p /sdcard/screenshot.pngadb pull /sdcard/screenshot.png ./Dowload/screenshot.png(保存到电脑)
    • Screen recording

      adb shell screenrecord  --time-limit 30 /sdcard/demo.mp4adb pull /sdcard/demo.mp4 ./Downloads/
Learn more Gityuan Instruction series Android common ADB command adb basic commands android common ADB command summary android video recording command Screenrecord

View Original: http://blog.csdn.net/u010818425/article/details/52266593

Android Common ADB commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.