【android】android 常用adb 和 adb shell 命令

來源:互聯網
上載者:User

標籤:

db是SDK內建的工具,可實現橋接功能;
adb shell 可以與手機系統建立互動,是基於andoid Linux系統下的操作

ADB常用命令:

1. 查看裝置
        adb  devices
  這個命令是查看當前串連的裝置, 串連到電腦的android裝置或者模擬器將會列出顯示

2. 安裝軟體
  adb  install <apk檔案路徑>
  這個命令將指定的apk檔案安裝到裝置上
       參數“-r”,它是更新安裝的意思,
       參數 -s ,安裝到sdcard.
       如: adb install com.sina.weibo.apk    

3. 卸載軟體
  adb  uninstall <包名>  
        如果加 -k 參數,為卸載軟體但是保留配置和快取檔案.
        如: adb uninstall com.sina.weibo.apk    

4. 登入裝置shell
  adb  shell
  adbshell <command命令>
  這個命令將登入裝置的shell.
  後面加<command命令>將是直接運行裝置命令, 相當於執行遠程命令
        如:    adb  shell cat /proc/kmsg

5. 從電腦上傳送檔案到裝置
  adb push <本地路徑> <遠程路徑>
  用push命令可以把本機電腦上的檔案或者檔案夾複製到裝置(手機)
        如: adb push /local/build.prop  /system/build.prop

6. 從裝置上下載檔案到電腦
  adb  pull <遠程路徑> <本地路徑>
  用pull命令可以把裝置(手機)上的檔案或者檔案夾複製到本機電腦
        如: adb  /system/build.prop  /local/

7. 同步更新
         adb sync [ <directory> ]
         如果不指定目錄,將同時更新 /data 和  /system/
         如: adb sync /data/

8. 顯示協助資訊
  adb  help
  這個命令將顯示協助資訊

9.  重新掛載
        adb  remount
        重新掛載系統  分區 用於讀寫
       
10.   啟 動和關閉
        adb start-server             - ensure that there is a server running
        adb kill-server              - kill the server if it is running

11. 重啟裝置
         adb reboot [bootloader|recovery]      - reboots the device, optionally into the bootloader or recovery program


12. 查看Log
         [adb] logcat [<option>] ... [<filter-spec>] ..
          -b <buffer> 載入一個可使用的日誌緩衝區供查看,比如event 和radio . 預設值是main 。具體查看Viewing     Alternative Log Buffers.
     -c 清楚螢幕上的日誌.
     -d 輸出日誌到螢幕上.
     -f <filename> 指定輸出日誌資訊的<filename> ,預設是stdout .
     -g 輸出指定的日誌緩衝區,輸出後退出.
     -n <count> 設定日誌的最大數目<count> .,預設值是4,需要和 -r 選項一起使用。
     -r <kbytes> 每<kbytes> 時輸出日誌,預設值為16,需要和-f 選項一起使用.
     -s 設定預設的過濾層級為silent.
     -v <format> 設定日誌輸入格式,預設的是brief 格式

    where <tag> is a log component tag (or * for all) and priority is:
      V    Verbose
      D    Debug
      I    Info
      W    Warn
      E    Error
      F    Fatal
      S    Silent (supress all output)

    ‘*‘ means ‘*:d‘ and <tag> by itself means <tag>:v


13、查看bug報告:
     adb bugreport












常用adb shell命令:

1.  按鍵事件
         input text <string>   input a string to device
         input keyevent <event_code>   send a Key Event to device
        如: adb shell input keyevent 26      (PowerKey)

2.  am命令
           am start  <INTENT> : start an Activity
           如 :
           am start -n com.android.calculator/com.android.calculator2.Calculator
               
           am broadcast <INTENT>
 
           am startservice <INTENT>
           am force-stop <PACKAGE>
           am kill <PACKAGE>
           am kill-all
           am broadcast <INTENT>

                 "<INTENT> specifications include these flags and arguments:\n" +
                "    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]\n" +
                "    [-c <CATEGORY> [-c <CATEGORY>] ...]\n" +
                "    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]\n" +
                "    [--esn <EXTRA_KEY> ...]\n" +
                "    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]\n" +
                "    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]\n" +
                "    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]\n" +
                "    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]\n" +
                "    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]\n" +
                "    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]\n"
                "    [-n <COMPONENT>] [-f <FLAGS>]\n" +
                "    [--grant-read-uri-permission] [--grant-write-uri-permission]\n" +
                "    [--debug-log-resolution] [--exclude-stopped-packages]\n" +
                "    [--include-stopped-packages]\n" +
                "    [--activity-brought-to-front] [--activity-clear-top]\n" +
                "    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]\n" +
                "    [--activity-launched-from-history] [--activity-multiple-task]\n" +
                "    [--activity-no-animation] [--activity-no-history]\n" +
                "    [--activity-no-user-action] [--activity-previous-is-top]\n" +
                "    [--activity-reorder-to-front] [--activity-reset-task-if-needed]\n" +
                "    [--activity-single-top] [--activity-clear-task]\n" +
                "    [--activity-task-on-home]\n" +
                "    [--receiver-registered-only] [--receiver-replace-pending]\n" +
                "    [--selector]\n" +
                "    [<URI> | <PACKAGE> | <COMPONENT>]\n"

     更多詳細用法請見am 使用協助.

3. pm 命令
             pm list packages    
        -f: see their associated file
        -s: filter to only show system packages
        -3 ilter to only show third party packages
    pm list packages [-f] [-d] [-e] [-s] [-e] [-u] [FILTER]");
     pm list permission-groups
    pm list permissions [-g] [-f] [-d] [-u] [GROUP]");
    pm list instrumentation [-f] [TARGET-PACKAGE]");
     pm list features
    pm list libraries
    pm path PACKAGE
    pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH
    pm uninstall [-k] PACKAGE
     pm clear PACKAGE
    pm enable PACKAGE_OR_COMPONENT
    pm disable PACKAGE_OR_COMPONENT
    pm disable-user PACKAGE_OR_COMPONENT
    pm set-install-location [0/auto] [1/internal] [2/external]
    pm get-install-location
    
    更多詳細用法,請見pm使用協助.

4. dumpsys
    dumpsys activit
        dumpsys activity intents
        dumpsys activity broadcasts
        dumpsys activity providers
        dumpsys activity services
        dumpsys activity activities
        dumpsys activity processes

    dumpsys window
        dumpsys window windows
        dumpsys window tokens
        dumpsys window sessions
        dumpsys window policy
        dumpsys window input

    dumpsys statusbar
    dumpsys notification
    dumpsys package  [<PACKAGE> ]
    dumpsys location
    dumpsys alarm
    dumpsys connectivity
    dumpsys wifi
    …....等等
    

5. ime    IME管理           
     ime list [-a] [-s]
    list command prints all enabled input methods
    -s option to see only a single summary line of each.
    -a option to see all input method

    ime enable ID
    ime disable ID
    ime set ID

【android】android 常用adb 和 adb shell 命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.