ADB Common Commands

Source: Internet
Author: User
Tags directory create system log cpu usage

    • View Connected Devices
ADB devices   //Display device list adb get-serialno   //Get device serial number
    • Restart ADB service
ADB kill-server adb start-server
    • ADB gain root control
ADB root adb remount   //re-mount the system partition as a read-write partition
    • ADB Shell View System Information
ADB shell cat/proc/meminfo   //query system memory information adb shell Cat/proc/cpuinfo   //query system cpuinfo ADB shell getprop   //query system Properties adb shell Getprop |grep ro.product.board   //Filter Ro.product.board properties adb shell cat/sys/class/net/wlan0/address
   
    //View MAC address adb shell cat/data/misc/wifi/*.conf   //view WiFi password (root is horrible)
   
    • ADB restart
adb shell stop;adb Shell start   //restart Android adb shell kill-9 system_server/zygote pid   //restart Android adb reboot
   
    //Restart phone adb reboot bootloader   //reboot to brush mode adb reboot recovery   //reboot to recovery, recovery mode
   
    • ADB push to put files into the phone
ADB push out/target/product/xx/system/bin/vold/system/bin/   //replace Vold in Phone, receive path best not to write system/bin, there will be problems
    • ADB pull files from the phone
ADB pull/data/data/com.android.providers.settings/databases/settings.db./   /Set the database on the phone to take out the ADB pull/data/anr/. /   //Remove all files in the ANR directory, including Trace.txt
    • adb sync Sync
First create a directory (such as create sync under Work), in this directory create system/and data directory, directory structure and phone consistent, directory placed in need to sync to the phone file export Android_product_out=/home/hunter /work/sync   Note: This is in the Linux environment, ADB sync//This time the   file will be push to sync to the phone, so you need root permissions
    • ADB logcat Print Log
ADB logcat   //Print all log adb shell Logcat   //ditto adb locat >./log.txt   //Redirect to Log.txt adb logcat |tee./log.txt   //Redirect to Log.txt, and in console output adb logcat-b main   //filter main log adb logcat-b events   //Filter Event log adb logcat-b rad Io   //filter Radio log adb logcat-b system   //filter system log (SLOG) adb logcat-s "TAG"   //filter log adb logcat *:e for a tag   //Filter error log adb logcat *:w   //filter warn log adb logcat mountservice:i VOLD:I *:s   //print tag for mountservice and Vold info above level of log adb logcat-v   time//Display date, call duration, priority/tag, PID adb logcat-v thr EAD//   Show only processes: thread and priority/tag adb logcat-c   //clear Log Cache
    • ADB shell view process, memory usage information
Vss-virtual set size virtual memory consumption (contains memory consumed by shared libraries) rss-resident set size actually uses physical memory (contains memory occupied by shared libraries) pss-proportional set size is actually used Physical memory (proportional allocation of memory consumed by shared libraries) Uss-unique Set Size process consumes physical memory alone (does not contain memory consumed by shared libraries)


    • ADB Shell Dumpsys
ADB shell Dumpsys activity   //Show activity-related information adb shell Dumpsys Activity Services   //View service usage details adb shell dumps YS   Package//Show all program information, including activity,receiver adb shell Dumpsys cpuinfo   //Display CPU usage information adb shell Dumpsys battery
   
    //Display battery status adb shell dumpsys window   //Display window information adb shell Dumpsys WiFi   //show WiFi info adb shell Dumpsys statusbar   / /Display status bar related information adb shell Dumpsys gfxinfo com.xxxx.xxx  //dump gfxinfo adb shell Dumpsys meminfo   //Display memory usage adb shel L Dumpsys meminfo com.android.settings   //Display set process memory usage information
   
    • ADB wireless connection (very helpful for debugging OTG,SD card mount issues)
1. Open the phone WiFi hotspot 2. Connect the data cable, make sure you can use ADB, perform adb tcpip 5555 3.pc via wireless network card, such as 360wifi, connect mobile hotspot 4.pc end to perform ADB connect 192.168.43.1, after the connection is successful, You can debug 5.adb disconnect disconnect without a data cable
    • Turn SELinux on/off (Android 5.0 or later for quick location is selinux cause problem)
adb shell Setenforce 1   //open selinux adb shell Setenforce 0   //Turn off SELinux
    • Screen recording (KK and later versions are only available)
ADB shell Screenrecord/sdcard/demo.mp4   //recorded video located on SD card adb shell Screenrecord  --time-limit 10/sdcard/demo.mp4< c4/>//Limit recording time, unit s adb shell Screenrecord--size 1280*720/sdcard/demo.mp4   //Specify video resolution size
    • ADB install app
ADB install xx.apk   //install apk adb install-s xx.apk   //install to SD card, need to set installation location to have system decision or external SD card adb install-r xx.apk   //mandatory Ann Install adb uninstall XXX (package name)   //uninstaller program adb shell pm uninstall-k xxx (package name)   /uninstall program, do not delete the produced Raw data and Cache directory
    • ADB Shell Input Command
  adb shell input text HelloWorld//Enter HelloWorld adb shell input keyevent 26//Input key value in text box, imitate click Powkey (Power key is broken it will be useful) ADB shell input Tap 0 0//Analog click Effect, click (0,0) position adb shell input swipe 500 1000 500 0//simulate sliding effect, from (500,1000) to (500,0)//Key value pairs   shall be as follows: KEYCODE_UNKNOWN&NBSP;: 0 keycode_menu : 1 keycode_soft_right : 2 keycode_home : 3 KEYCODE_BACK&NBSP: 4 keycode_call : 5 keycode_endcall : 6 keycode_0 : 7 keycode _1&NBSP: 8 keycode_2 : 9 keycode_3 : ten keycode_4 : keycode_5            : keycode_6 : keycode_7 : keycode_8 : keycode_9 : 16 KEYCODE_STAR&NBSP: keycode_pound : keycode_dpad_up : keycode_dpad_down : KEYCODE_DPAD_LEFT&NBSP: £ keycode_dpad_right : keycode_dpad_center : keycode_volume_up  : Keycode_volume_doWN&NBSP: keycode_power : keycode_camera : keycode_clear : keycode_a : 29            KEYCODE_B&NBSP: keycode_c : keycode_d : keycode_e : 33 KEYCODE_F&NBSP: keycode_g : keycode_h : + keycode_i : Panax Notoginseng Keyco DE_J&NBSP: keycode_k : keycode_l : + keycode_m : Keycode_n&nbs             P: keycode_o : keycode_p : keycode_q : keycode_r : 46             KEYCODE_S&NBSP: keycode_t : keycode_u : £ keycode_v : 50 KEYCODE_W&NBSP: Wuyi keycode_x : keycode_y : keycode_z : Wu Keyco DE_COMMA&NBSP: keycode_period : keycode_alt_left : keycode_alt_right : KEYCODE_S hift_left : KEYCODE_SHIFT_RIGHT&NBSP: keycode_tab : keycode_space : keycode_sym : keycode_e XPLORER&NBSP: keycode_envelope : keycode_enter : keycode_del : KEYCODE_GRAVE&N BSP: keycode_minus : keycode_equals : keycode_left_bracket : Keycode_slas H&NBSP: keycode_at : keycode_num : + keycode_headsethook : Keycode_fo CUS&NBSP: keycode_plus : Bayi keycode_menu : keycode_notification : keycode _SEARCH&NBSP: tag_last_keycode : keycode_right_bracket : keycode_backslash : KEYCODE _semicolon : keycode_apostrophe : 75


    • ADB shell am start starts an activity
ADB shell am start-a xxx (Action,eg:android.intent.action.view)   //Start activity action adb shell AM start-n xxx/.xx (PAC kage/.class,eg:com.android.settings/.  Settings)   //Start activity adb shell am start-a android.intent.action.call-d tel:10086  //Give 10086 call a phone adb shell am Start-a android.intent.action.view-d http://www.baidu.com   //Open a webpage
    • ADB shell am startservice start a service
ADB shell am startservice-a xxx (action,eg:android.media.imediascannerservice)   //Start a service action adb shell am STA Rtservice-n xxx/.xx (package/.class,eg:com.android.providers.media/. Mediascannerservice)   //Start a service
    • ADB shell AM broadcast send a broadcast
ADB shell am broadcast-a xxx (action,eg:android.intent.action.media_scanner_finished)   //Start a broadcast action adb shell AM B Roadcast-n xxx/.xx   //Start a broadcast adb shell am broadcast-a android.intent.action.media_scanner_finished-d file:///syste M/media   //Send built-in SD card scan complete broadcast
    • ADB shell PM
ADB shell PM List Packages   //list all packages on phone adb shell pm Clear xxx (package name)   //Purge program Data adb shell PM get-install-location
   
    //Get application install location adb shell pm set-install-location 2   //Set Application installation location for external ([0/auto] [1/internal] [2/external]) adb shell pm u Ninstall [-K] XXX (package name)   //Retention Data uninstaller program adb shell pm Disable XXX (package name)   //Estoppel program adb shell pm Enable XXX (package name)   //Enabler Program
   
    • ADB shell am force-stop force an app to close
ADB shell am force-stop xxx (package name,eg:com.android.deskclock)   //force off an app
    • ADB shell Service display system service
ADB shell service   list//display service listing
    • ADB Monkey
ADB shell monkey-v   //Generate 500 random events adb shell monkey-v-P com.android.settings   //100 random events for set app execution
    • ADB shell IME Input Management
ADB shell IME list   //Display Input Method adb shell IME enable ID (com.sohu.inputmethod.sogou/. Sogouime)   //Enable Input method adb shell IME disable ID (com.sohu.inputmethod.sogou/. Sogouime)   //Disable Input Method adb shell IME set ID (com.sohu.inputmethod.sogou/. Sogouime)   //Set Current Input method
    • ADB shell rm deletes files from your phone
ADB shell Rm/data/system/gesture.key   //delete gesture password, you know.
    • ADB Shell Set Date
adb shell date-s "20120801.120503"   //Set the system date to 2012.08.01.12.05.03
    • Official documents
Http://developer.android.com/tools/help/adb.html

ADB Common 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.