A. 鎶鏈鍒嗕韓 | App嫻嬭瘯鏃跺父鐢ㄧ殑adb鍛戒護浣犻兘鎺屾彙浜嗗摢浜涘憿錛
adb 鍏ㄧО涓 Android Debug Bridge錛圓ndroid 璋冭瘯妗ワ級錛屾槸 Android SDK 涓鎻愪緵鐨勭敤浜庣$悊 Android 妯℃嫙鍣ㄦ垨鐪熸満鐨勫伐鍏楓
adb 鏄涓縐嶅姛鑳藉己澶х殑鍛戒護琛屽伐鍏鳳紝鍙璁 PC 絝涓 Android 璁懼囪繘琛岄氫俊銆俛db 鍛戒護鍙鎵ц屽悇縐嶈懼囨搷浣滐紝渚嬪傚畨瑁呭拰璋冭瘯搴旂敤銆
閲囩敤浜嗗㈡埛絝-鏈嶅姟鍣錛圕/S錛夋ā鍨嬶紝鍖呮嫭涓変釜閮ㄥ垎錛
褰 adb 瀹㈡埛絝鍚鍔ㄦ椂錛屽㈡埛絝浼氬厛媯鏌 adb 鏈嶅姟絝鏄鍚﹀惎鍔ㄣ傚傛灉娌℃湁錛屼細鍏堝惎鍔ㄦ湇鍔$榪涚▼銆俛db 鏈嶅姟絝鍦ㄥ惎鍔ㄥ悗錛屼細涓 5037 絝鍙g粦瀹氾紝騫剁洃鍚 adb 瀹㈡埛絝鍙戝嚭鐨勫懡浠ゃ
鐒跺悗鏈嶅姟絝浼氫笌鎵鏈夋e湪榪愯岀殑 Android 璁懼囧緩絝嬭繛鎺ャ傚畠閫氳繃鎵鎻 5555 鍒 5585 涔嬮棿鐨勫囨暟鍙風鍙f煡鎵 Android 璁懼囥傛湇鍔$涓鏃﹀彂鐜 Android 璁懼囦笂鐨 adb 瀹堟姢榪涚▼鍦ㄨ繍琛岋紝渚誇細涓庣浉搴旂殑絝鍙e緩絝嬭繛鎺ャ傛瘡涓 Android 璁懼囬兘浣跨敤涓瀵圭鍙o紝鍋舵暟絝鍙g敤浜庢帶鍒跺彴榪炴帴錛屽囨暟絝鍙g敤浜 adb 榪炴帴銆
鏈嶅姟絝涓庢墍鏈 Android 璁懼囧緩絝嬭繛鎺ュ悗錛屽氨鍙浠ヤ嬌鐢 adb 鍛戒護鏉ヨ塊棶榪欎簺璁懼囦簡銆傛湇鍔$浼氱$悊宸茬粡寤虹珛鐨勮繛鎺ワ紝騫跺勭悊鏉ヨ嚜 adb 瀹㈡埛絝鐨勫懡浠ゃ
Android 鐪熸満鍙浠ラ氳繃 USB 榪炴帴鍒 adb錛岃繛鎺ユ椂闇瑕佸湪璁懼囩殑緋葷粺璁劇疆涓鍚鐢 USB 璋冭瘯錛堜綅浜庡紑鍙戣呴夐」涓嬶級錛屽惎鍔 USB 璋冭瘯鍚庯紝璁懼囦笂鐨 adb 瀹堟姢榪涚▼灝變細琚鍚鍔錛宎db 鏈嶅姟絝鎵嶅彲浠ュ拰璁懼囧緩絝嬭繛鎺ャ傞櫎浜嗙敤 USB 鐨勬柟寮忚繛鎺ヤ箣澶栵紝涔熷彲浠ラ氳繃 WLAN 鐨勬柟寮忚繛鎺ワ紝榪欑嶆柟寮忎笉鍋氳禈榪般
鏂規嫭鍙蜂腑鐨勫唴瀹規槸鍙閫夌殑錛屽皷鎷鍙峰唴瀹圭殑鏄蹇呭~鐨勩傛柟鎷鍙蜂腑鍙傛暟鍙浠ユ寚瀹氳懼囷紝鍏充簬璁懼囩殑鎸囧畾鏈変笁涓鍙傛暟鍙浠ヤ嬌鐢ㄣ-d銆-e 鍜 -s錛屽叾涓浣跨敤鏈澶氱殑鏄 -s 鍙傛暟錛屽湪榪炴帴澶氬彴璁懼囩殑鏃跺欙紝涓鑸閮芥槸浣跨敤 -s 鍔犱笂璁懼囩殑搴忓垪鍙瘋繖縐嶆柟寮忓幓鎸囧畾鍏蜂綋璁懼囥
adb 鍙浠ュ悓鏃惰繛鎺ュ氬彴璁懼囷紝浣嗘槸涓嬈″彧鑳藉逛竴鍙拌懼囨墽琛屽懡浠ゃ傛墍鏈夎繛鎺ュ氬彴璁懼囩殑鏃跺欙紝鏄蹇呴』瑕佸埗瀹氳懼囷紝鍛戒護鎵嶅彲浠ユ墽琛屾垚鍔熺殑銆
鎶 Android 璁懼囪繛鎺ュ埌 adb 鏈嶅姟絝鍚庯紝闇瑕佺『璁よ懼囩殑榪炴帴鐘舵併傝繖鏃跺彲浠ヤ嬌鐢ㄦ煡璇㈠懡浠よ繘琛屾煡璇銆
Windows 緋葷粺涓錛岃繛鎺ユā鎷熷櫒闇瑕佸厛鎵ц connect 鍛戒護鍘昏繛鎺ユā鎷熷櫒錛127.0.0.1 鏄鏈鍦扮殑 IP 鍦板潃錛屽洜涓烘ā鎷熷櫒灝辨槸瀹夎呭湪鏈鍦扮殑錛屾墍浠ヨ佷嬌鐢ㄦ湰鍦扮殑 IP 鍦板潃錛屽姞涓婃ā鎷熷櫒鏈韜瑙勫畾鐨勪竴涓絝鍙e彿銆俶umu 鐨勭鍙e彿鏄 7555錛屽傛灉浣跨敤鐨勬槸鍏朵粬鐨勬ā鎷熷櫒鐨勮瘽錛岄渶瑕佸厛鍘諱簡瑙e畠鐨勭鍙e彿鏄浠涔堬紝鐒跺悗鍐嶅幓榪炴帴銆侻acOS 緋葷粺涓榪炴帴妯℃嫙鍣ㄤ笉闇瑕佸厛鎵ц connect 鍛戒護錛岀洿鎺ユ墽琛 adb kill-server && adb devices 鍛戒護鍗沖彲銆
鐪熸満鐩存帴鐢 USB 榪炴帴鍒扮數鑴戱紝涓嶉渶瑕佹墽琛 connect 鍛戒護銆
鐩存帴鐢 adb devices 鍛戒護鏌ョ湅宸茬粡榪炴帴鐨勮懼囧垪琛ㄥ嵆鍙銆
鐩存帴鍛戒護鍚庯紝濡傛灉璁懼囧凡緇忔垚鍔熻繛鎺ワ紝閭d箞璁懼囧垪琛ㄤ腑灝變細灞曠ず宸茶繛鎺ヨ懼囩殑淇℃伅銆
嫻嬭瘯榪囩▼涓錛屽傛灉闇瑕佸畨瑁呮垨鑰呭嵏杞藉簲鐢錛屽彲浠ョ洿鎺ョ敤 adb 鍛戒護鏉ユ搷浣溿
adb 鍛戒護鏀鎸佺數鑴戝拰 Android 璁懼囦箣闂寸殑鏂囦歡浜掍紶銆傛瘮濡傝佹彁鍙 Android 璁懼囦腑鐨勬棩蹇楁枃浠跺埌鏈鍦幫紝灝卞彲浠ラ氳繃 adb 鍛戒護鐨勬柟寮忔潵瀹屾垚銆
鎵撳嵃閾炬帴璁懼囩殑 log 淇℃伅
浣跨敤 adb shell 鍛戒護鐩稿綋浜庤繙紼嬬櫥褰曚簡 Android 緋葷粺錛屽彲浠ヨ繘鍏 Android 璁懼囩殑緋葷粺鍐呴儴銆傝繘鍏ョ郴緇熷唴閮ㄦ棦鍙浠ユ墽琛屼竴浜涚畝鍗曠殑 Linux 鍛戒護涔熸敮鎸佸緢澶氱壒鏈夌殑鍛戒護銆
浣跨敤 adb shell 鍛戒護鏈変袱縐嶆柟寮忋
涓縐嶆槸鐩存帴鍦 adb shell 鍚庨潰璺熶笂鍛戒護銆
姣斿傦細
鍙︿竴縐嶆柟寮忔槸鍦ㄨ懼囦笂鍚鍔ㄤ氦浜掑紡 shell
榪涘叆 shell 涔嬪悗錛屽啀鎵ц屽瑰簲鐨勫懡浠ゃ
姣斿傝繘鍏ヨ懼囧唴閮錛屽彲浠ユ煡鐪嬭懼囧唴閮ㄧ殑鐩褰曠粨鏋勫拰鍐呭
瑕侀鍑轟氦浜掑紡 shell錛屽彲浠ユ寜 Ctrl + D 閿鎴栬緭鍏 exit銆
鍦ㄦ祴璇曡繃紼嬩腑錛屽傛灉闇瑕佹埅鍥炬垨鑰呮槸褰曞睆錛屼篃鍙浠ョ洿鎺ヤ嬌鐢 adb 鍛戒護鏉ュ畬鎴愩
鍦 adb shell 涓錛屽彲浠ヤ嬌鐢 Activity 綆$悊鍣 (am) 宸ュ叿鍙戝嚭鍛戒護浠ユ墽琛屽悇縐嶇郴緇熸搷浣滐紝濡傚惎鍔 Activity銆佸己琛屽仠姝㈣繘紼嬨佷慨鏀硅懼囧睆騫曞睘鎬э紝絳夌瓑銆
鍦ㄦ祴璇曡繃紼嬩腑錛屽傛灉闇瑕佸惎鍔 app 鎴栬呭己鍒跺叧闂 app錛屽彲浠ラ氳繃 adb 鍛戒護鏉ュ疄鐜般
鍦 adb shell 涓錛屽彲浠ヤ嬌鐢ㄨ蔣浠跺寘綆$悊鍣 (pm) 宸ュ叿鍙戝嚭鍛戒護錛屼互瀵硅懼囦笂瀹夎呯殑搴旂敤杞浠跺寘鎵ц屾搷浣滃拰鏌ヨ銆
濡傛灉闇瑕佹煡璇㈣懼囬噷閮藉畨瑁呬簡浠涔堝簲鐢錛屽氨鍙浠ヤ嬌鐢 adb shell pm list 鏉ユ煡鐪嬶紝榪樺彲浠ュ姞涓婁笉鍚岀殑鍙傛暟鍘繪煡鐪嬩笉鍚岀被鍨嬬殑搴旂敤銆傝屼笖涔熷彲浠ラ氳繃 adb 鍛戒護鏉ユ竻闄ゅ簲鐢ㄧ浉鍏崇殑鏁版嵁銆
mpsys 鏄涓縐嶅湪 Android 璁懼囦笂榪愯岀殑宸ュ叿錛屽彲鎻愪緵鏈夊叧緋葷粺鏈嶅姟鐨勪俊鎮銆傚彲浠ヤ嬌鐢 adb 浠庡懡浠よ岃皟鐢 mpsys錛岃幏鍙栧湪榪炴帴鐨勮懼囦笂榪愯岀殑鎵鏈夌郴緇熸湇鍔$殑璇婃柇杈撳嚭銆
姣斿傚湪嫻嬭瘯涓錛屽傛灉闇瑕侀氳繃 adb 鍛戒護鍚鍔 app錛屽垯闇瑕佺煡閬 app 鐨勫寘鍚嶅拰鍏ュ彛鐨 Activity 鍚嶃傝繖涓鏃跺欙紝灝卞彲浠ラ氳繃涓嬮潰榪欐潯鍛戒護鑾峰彇鍒拌繖涓や釜淇℃伅銆
榪欎釜鍦烘櫙錛岄渶瑕佸厛鎶婅佽幏鍙栦俊鎮鐨勫簲鐢ㄥ惎鍔錛岃╁畠鍦ㄥ墠鍙拌繍琛岋紝鐒跺悗鎵ц屽懡浠
adb shell mpsys activity | grep mFocusedActivity
涓嬫柟鐨勬棩蹇椾腑灝變細灞曠ず鍑烘潵褰撳墠鐨勫寘鍚嶅拰 Activity 鍚嶇О銆
adb 鍛戒護榪樻敮鎸佺洿鎺ヨ幏鍙栧簲鐢ㄧ殑欏甸潰淇℃伅銆傝繖涓欏甸潰淇℃伅鍖呭惈浜嗛〉闈涓鍏冪礌鐨勫睘鎬э紝鍙浠ユ柟渚垮仛鑷鍔ㄥ寲嫻嬭瘯鐨勬椂鍊欏幓瀹氫綅鍏冪礌銆傝幏鍙栧埌鐨勯〉闈㈠竷灞浼氳緭鍑哄埌涓涓 xml 鏂囦歡涓銆
涓嶆寚瀹氳緭鍑烘枃浠惰礬寰勬椂錛宒ump 涓嬫潵鐨勬枃浠墮粯璁ゅ瓨鍌ㄨ礬寰勪負 /sdcard/window_mp.xml
鍙浠ラ氳繃 adb pull 鍛戒護鎶婃枃浠朵紶杈撳埌鐢佃剳涓錛岀劧鍚庣敤 uiautomatorviewer 宸ュ叿鎵撳紑鏌ョ湅甯冨矓銆
浣犲ソ鍛錛屽枩嬈㈣繖綃囨枃絝犵殑璇濈儲璇風偣涓鈥滆禐鈥濆摝錛佷竾鍒嗘劅璋~( 鈻 ) PS錛氭湁闂棰樺彲浠ヨ仈緋繪垜浠鍝~v ceshiren001