android adb 通過adb連接制定設備


(移植android OS 到 openwrt)

確保linux能夠識別adb命令,請自行添加環境變量。

root@Ray:/home/floyd/adt-bundle-linux/sdk/platform-tools# ./adb devices -l
List of devices attached 
02a0251d               device usb:2-1.1

注,確保adb運行權限為root,否則

floyd@Ray:~/adt-bundle-linux/sdk/platform-tools$ ./adb devices -l
List of devices attached 
????????????           no permissions usb:2-1.1

且無法使用adb -s  device_id shell連接設備。

root@Ray:/home/floyd/adt-bundle-linux/sdk/platform-tools# ./adb -s 02a0251d shell
$ ls
acct                 init.goldfish.rc     sbin
cache                init.qcom.rc         sd-ext
config               init.qcom.sh         sdcard
d                    init.rc              sys
data                 init.target.rc       system
default.prop         mnt                  ueventd.goldfish.rc
dev                  persist              ueventd.rc
etc                  proc                 vendor
init                 root

如何連接開發板

adb connect 192.168.1.2:5555 #端口5555,192.168.1.2為開發板IP
adb shell #進入終端模式

adb的關閉與啟動

root@Ray:/home/floyd/adt-bundle-linux/sdk/platform-tools# ./adb kill-server
root@Ray:/home/floyd/adt-bundle-linux/sdk/platform-tools# ./adb start-server

與設備之間文件的傳輸

adb push <本機文件目錄> <設備文件目錄>

adb pull <本機文件目錄> <設備文件目錄>

安裝APK程序到設備

adb install <APK文件路徑>

連接到Android設備后請求root權限,su,如果手機的話,注意在手機上允許root權限請求。

默認下apk軟件安裝到/data/app

adb命令啟動Android程序

adb shell am start -n breakan.test/breakan.test.TestActivity

其中"breakan.test/breakan.test.TestActivity"中的"breakan.test"是程序的包名,"TestActivity"是程序Activity類的類名。

usage: am [subcommand] [options]

    start an Activity: am start [-D] [-W] <INTENT>
        -D: enable debugging
        -W: wait for launch to complete

    start a Service: am startservice <INTENT>

    send a broadcast Intent: am broadcast <INTENT>

    start an Instrumentation: am instrument [flags] <COMPONENT>
        -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
        -e <NAME> <VALUE>: set argument <NAME> to <VALUE>
        -p <FILE>: write profiling data to <FILE>
        -w: wait for instrumentation to finish before returning

    start profiling: am profile <PROCESS> start <FILE>
    stop profiling: am profile <PROCESS> stop

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

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM