Adb命令

1、獲取序列號(hào):

adb get-serialno

2、查看連接計(jì)算機(jī)的設(shè)備:

adb devices

3、重啟機(jī)器:

adb reboot

4、終止adb服務(wù)進(jìn)程:

adb kill-server

5、重啟adb服務(wù)進(jìn)程:

adb start-server

6、獲取機(jī)器MAC地址:

adb shell? cat /sys/class/net/wlan0/address

7、獲取CPU序列號(hào):

adb shell cat /proc/cpuinfo

8、安裝APK:

adb install <apkfile> //比如:adb install baidu.apk

9、保留數(shù)據(jù)和緩存文件,重新安裝apk:

adb install -r <apkfile> //比如:adb install -r baidu.apk

10、安裝apk到sd卡:

adb install -s <apkfile> // 比如:adb install -s baidu.apk

11、卸載APK:

adb uninstall <package> //比如:adb uninstall com.baidu.search

12、卸載app但保留數(shù)據(jù)和緩存文件:

adb uninstall -k <package> //比如:adb uninstall -k com.baidu.search

13、熱啟動(dòng)應(yīng)用:

adb shell am start -n <package_name>/.<activity_class_name>

14、查看設(shè)備cpu和內(nèi)存占用情況:

adb shell top

15、查看占用內(nèi)存前6的app:

adb shell top -m 6

16、刷新一次內(nèi)存信息,然后返回:

adb shell top -n 1

17、查詢各進(jìn)程內(nèi)存使用情況:

adb shell procrank

18、殺死一個(gè)進(jìn)程:

adb shell kill [pid]

18、查看進(jìn)程列表:

adb shell ps

20、查看指定進(jìn)程狀態(tài):

adb shell ps -x [PID]

21、查看當(dāng)前內(nèi)存占用:

adb shell cat /proc/meminfo

22、從本地復(fù)制文件到設(shè)備:

adb push <local> <remote>

23、從設(shè)備復(fù)制文件到本地:

adb pull <remote>? <local>

24、列出目錄下的文件和文件夾,等同于dos中的dir命令:

adb shell ls

25、進(jìn)入文件夾,等同于dos中的cd 命令:

adb shell cd <folder>

26、重命名文件:

adb shell rename path/oldfilename path/newfilename

27、刪除system/avi.apk:

adb shell rm /system/avi.apk

28、刪除文件夾及其下面所有文件:

adb shell rm -r <folder>

29、設(shè)置文件權(quán)限:

adb shell chmod 777 /system/fonts/DroidSansFallback.ttf

30、查看文件內(nèi)容:

adb shell cat <file>

31、清除log緩存:

adb logcat -c

32、跑monkey:

adb shell monkey -v -p your.package.name 500

33.獲取--手機(jī)應(yīng)用的包名和activity

adb shell dumpsys activity | grep mFocusedActivity

34. 進(jìn)入指定的device的shell

adb shell

35.adb 查看所有安裝的包

pm list packages

36.根據(jù)某個(gè)關(guān)鍵字查找包

$ pm list packages | grep turing

37. 查看包安裝位置

$ pm list packages -f

38. 同樣可以進(jìn)行篩選

$ pm list packages -f | grep tencent

39.如何查看IP地址:

adb shell

ifconfig

adb shell

netcfg

40、adb shell wm size----屏幕分辨率

adb shell dumpsys window displays

輸出:

Physical size: 1080x1920

41、試了QQ、口袋故事,退出應(yīng)用后,應(yīng)用是否運(yùn)行

adb shell dumpsys package com.turing.turingwatchgame.*****? | findstr versionName

adb shell dumpsys package com.appshare.android.ilisten.*****? | findstr versionName

adb shell dumpsys package com.tencent.*****? | findstr versionName

使用adb命令(前提是已安裝應(yīng)用)

adb shell dumpsys package?[PackageName] (查看的信息更多)

adb shell dumpsys package [PackageName] | findstr versionCode(直接顯示versioncode值)

adb shell dumpsys package [PackageName] | findstr versionName(直接顯示versionname值)

42、判斷應(yīng)用是否正在運(yùn)行

adb shell ps|findstr com.turing.turingwatchgame.*****(android版本低于7.0)

adb shell ps com.turing.turingwatchgame.*****(android版本低于7.0)

adb shell pidof com.turing.turingwatchgame.*****(Android系統(tǒng)>=7.0)

adb shell pidof com.appshare.android.ilisten.*****(Android系統(tǒng)>=7.0)

adb shell pidof com.tencent.*****(Android系統(tǒng)>=7.0)

Android系統(tǒng)>=7.0,用該adb命令可以判斷進(jìn)程是否退出:adb shell pidof 包名

如果找到此類進(jìn)程,則返回PID,否則返回空字符串。

43、查詢當(dāng)前運(yùn)行的應(yīng)用包名

adb shell am monitor

44、查看當(dāng)前系統(tǒng)版本:

adb shell getprop ro.build.version.release

45、查詢當(dāng)前端口

adb shell netstat

46、 列出所有的包名

1> adb shell pm list packages? 列出所有的包名(不知道包名的情況,需要執(zhí)行查找包名)appPackage

2> adb shell dumpsys package XXX? ? ?? ?查看某個(gè)包的具體信息(前提是需要知道包名是什么) ? ? ?appActivity

?3> adb shell dumpsys activity | grep mFocusedActivity? 查看當(dāng)前resume的是哪個(gè)activity?

?4> adb logcat | grep ActivityManager? ? ? ? ? ? ? 查看當(dāng)前正在運(yùn)行的Activity

?5> adb logcat | grep Displayed? ? ? ? ? ? ? ? ? ? ? ? 查看當(dāng)前正在運(yùn)行的Activity

47、logcat日志中的優(yōu)先級(jí)/tag標(biāo)記:

android輸出的每一條日志都有一個(gè)標(biāo)記和優(yōu)先級(jí)與其關(guān)聯(lián)。

優(yōu)先級(jí)是下面的字符,順序是從低到高:

V — 明細(xì) verbose(最低優(yōu)先級(jí))

D — 調(diào)試 debug

I — 信息 info

W — 警告 warn

E — 錯(cuò)誤 error

F — 嚴(yán)重錯(cuò)誤 fatal

S — 無(wú)記載 silent

48、adb 查看android手機(jī)中應(yīng)用的包名和安裝位置

adb devices

49.將apk拉到pc中

$ adb pull /data/app/com.tencent.tbs-1/base.apk ~/Downloads

adb shell pm lists package

口袋故事:com.appshare.android.ilisten.****

QQ:com.tencent.****

學(xué)霸小精靈:com.aobi.****

adb shell pm path com.appshare.android.ilisten.****

奇妙書:com.wjxx.magic***

成功舉例:adb pull /data/app/com.appshare.android.ilisten.****-1.apk C:\Users\Administrator

50、應(yīng)用安裝的位置

adb shell

pm setInstallLocation 0

注:不同的setInstallLocation說(shuō)明:

pm set-install-location 0 由App自行決定軟件能否安裝在SD卡

pm set-install-location 1 強(qiáng)制全部App安裝在ROM內(nèi)

pm set-install-location ?2 強(qiáng)制全部App安裝在SD卡

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容