adb常用命令及遇到的問題總結
阿新 • • 發佈:2019-01-27
1.檢視裝置
$ adb devices
List of devices attached
emulator-5554 device
6651084d70b674 device
2. 連線特定裝置
-d 連線的device,只能有一個,否則會報錯
-e 連線的模擬器,只能有一個,否則報錯
-s 指定特定的裝置或模擬器
3. 進入裝置的shell
$ adb -d shell
$ adb -e shell
4. 安裝/解除安裝apk
$ adb -e install ~/Downloads/apk/_b_9.5.101.apk
2658 KB/s (3803627 bytes in 1.397s)
pkg: /data/local/tmp/_b_9.5.101.apk
Success
解除安裝應用程式
$ adb uninstall app_name
安裝的應用程式在/data/data/目錄下,可在目錄下直接檢視app_name,或通過下面的方法。
app_name是在AndroidManifest.xml中<manifest>節點下,package元素所指定的名字
將原來apk解壓得到的AndroidManifest.xml,開啟是亂碼,需要使用apktool反編譯得到AndroidManifest.xml,才能開啟正常看。
$ apktool d ~/Downloads/apk/_b_9.5.101.apk
在當前目錄下得到_b_9.5.101目錄
查詢app安裝好後的名字
$ cat _b_9.5.101/AndroidManifest.xml |grep manifest
<manifest android:versionCode="1101" android:versionName="9.5.101" android:installLocation="auto" package="cn.chinabus.main"
</manifest>
$ adb uninstall cn.chinabus.main
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
Success
5. 傳輸檔案(push/pull)
$ adb pull /init.rc ~/Downloads/
533 KB/s (24001 bytes in 0.043s)
$ adb push ~/Downloads/adb_usb.ini /data
0 KB/s (7 bytes in 0.062s)
6. logcat
If you want to control the format of each log entry is dumped, you need to use the "adb logcat -v <format>" option, which supports the following formats:
"adb logcat -v brief" - Display priority/tag and the PID of process issuing the message (the default format).
"adb logcat -v process" - Display PID only.
"adb logcat -v tag" - Display the priority/tag only.
"adb logcat -v raw" - Display the raw log message, with no other metadata fields.
"adb logcat -v time" - Display the date, invocation time, priority/tag, and PID of the process issuing the message.
"adb logcat -v thread" - Display the priority, tag, and the PID and TID of the thread issuing the message.
"adb logcat -v threadtime" - Display the date, invocation time, priority, tag, and the PID and TID of the thread issuing the message.
"adb logcat -v long" - Display all metadata fields and separate messages with a blank lines.
一般使用這個引數
$ adb logcat -v threadtime &
7. 埠轉發
$ adb forward tcp:port tcp:port
在使用gdb或ARM DS-5, host和target需要進行通訊時,要設定這個,否則無法正常通訊。
adb 常見問題
1. adb devices no permissions
$ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
???????????? no permissions
$ adb devices
List of devices attached
emulator-5554 device
6651084d70b674 device
2. 連線特定裝置
-d 連線的device,只能有一個,否則會報錯
-e 連線的模擬器,只能有一個,否則報錯
-s 指定特定的裝置或模擬器
3. 進入裝置的shell
$ adb -d shell
$ adb -e shell
4. 安裝/解除安裝apk
$ adb -e install ~/Downloads/apk/_b_9.5.101.apk
2658 KB/s (3803627 bytes in 1.397s)
pkg: /data/local/tmp/_b_9.5.101.apk
Success
解除安裝應用程式
$ adb uninstall app_name
安裝的應用程式在/data/data/目錄下,可在目錄下直接檢視app_name,或通過下面的方法。
app_name是在AndroidManifest.xml中<manifest>節點下,package元素所指定的名字
將原來apk解壓得到的AndroidManifest.xml,開啟是亂碼,需要使用apktool反編譯得到AndroidManifest.xml,才能開啟正常看。
$ apktool d ~/Downloads/apk/_b_9.5.101.apk
在當前目錄下得到_b_9.5.101目錄
查詢app安裝好後的名字
$ cat _b_9.5.101/AndroidManifest.xml |grep manifest
<manifest android:versionCode="1101" android:versionName="9.5.101" android:installLocation="auto" package="cn.chinabus.main"
</manifest>
$ adb uninstall cn.chinabus.main
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
Success
5. 傳輸檔案(push/pull)
$ adb pull /init.rc ~/Downloads/
533 KB/s (24001 bytes in 0.043s)
$ adb push ~/Downloads/adb_usb.ini /data
0 KB/s (7 bytes in 0.062s)
6. logcat
If you want to control the format of each log entry is dumped, you need to use the "adb logcat -v <format>" option, which supports the following formats:
"adb logcat -v brief" - Display priority/tag and the PID of process issuing the message (the default format).
"adb logcat -v process" - Display PID only.
"adb logcat -v tag" - Display the priority/tag only.
"adb logcat -v raw" - Display the raw log message, with no other metadata fields.
"adb logcat -v time" - Display the date, invocation time, priority/tag, and PID of the process issuing the message.
"adb logcat -v thread" - Display the priority, tag, and the PID and TID of the thread issuing the message.
"adb logcat -v threadtime" - Display the date, invocation time, priority, tag, and the PID and TID of the thread issuing the message.
"adb logcat -v long" - Display all metadata fields and separate messages with a blank lines.
一般使用這個引數
$ adb logcat -v threadtime &
7. 埠轉發
$ adb forward tcp:port tcp:port
在使用gdb或ARM DS-5, host和target需要進行通訊時,要設定這個,否則無法正常通訊。
adb 常見問題
1. adb devices no permissions
$ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
???????????? no permissions