Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Getting started with adb shell

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

A brief introduction to ADB

ADB (Android Debug Bridge) is an irreplaceable general command line tool for Android developers / testers that allows communication with simulator instances or connected Android devices. It facilitates the operation of a variety of devices, such as installing and debugging applications, and provides access to Unix shell, which can be used to run various commands on simulators or connected devices. The Android system is based on the Linux kernel, so many commands in Linux have the same or similar implementation in Android and can be called in adb shell. The tool is a client-server program.

Client: the client runs on the development computer. You can invoke the client from the command line terminal by issuing the adb command.

Daemon: the daemon runs as a background process on each simulator or device instance. Http://www.daiqiyang.com

Server: the server runs as a background process on the development computer.

Second, installation: download adb from the Internet and extract it to the custom path, then configure the environment variables.

Third, connect:

ADB binds to local TCP port 5037 and listens for commands sent from adb clients (all adb clients use port 5037 to communicate with the adb server).

Connect the Android simulator

Night God Simulator: adb connect 127.0.0.1purl 62001

2.USB connects Android Devic

a. Open developer options

Settings > About phone > continuous click Build number

b. Turn on USB debugging

C. Enter adb devices under dos to verify whether the phone is connected to adb.

3. The phone and the computer are connected to the same local area network adb connect ip

IV. Common commands

1. Install the application

(1) do not have spaces in the adb install D:\ adbtest\ baidu.apk file name

(2) adb push D:\ adbtest\ baidu.apk / system/app

Will overwrite the corresponding apk in the original system

Adb pull / system/app/baidu.apk / home/ backups are available

Sometimes there will be Read-only errors, we can use the force install command to install apk

Adb install-r D:\ adbtest\ baidu.apk

2. Uninstall

Adb uninstall com.baidu.browser.apps

3. Import / export files to the phone

Adb pull remote local

Adb push local remote

4. Package management command pm

Adb shell pm list packages-3 View third-party installation packages

View the apk installation path based on the package name

Adb shell pm path com.baidu.browser.apps package name

Clear app data

Adb shell pm clear com.baidu.browser.apps package name

5. Dump the dumpsys query system service to the screen:

View all activity

Adb shell dumpsys activity activities 、

Get the currently running Activity

Adb shell dumpsys activity | findstr Run

6. View the system process

Adb shell top

Adb shell ps

Ps provides only a snapshot of the current process. Top instantly views the most active processes

7. Grab log adb logcat

Adb logcat-v time: e > D:\ test.log grabs the log and outputs it to the specified path

Adb logcat ActivityManager:i: s

Only the desired output (whitelist) is displayed and filtered through the pipe using grep.

Reference material (https://www.cnblogs.com/bydzhangxiaowei/p/8168598.html)

8. Adb shell monkey stress test

Reference material (https://www.cnblogs.com/yindada/p/9845032.html)

Adb shell monkey-p com.baidu.browser.apps-v 1000 > d:\ adbtest\ monkey_test.txt

-p, this command is used to specify the package and, if not specified, is executed throughout the system

-v, which is used to feedback the level of detail of the log

Level 0: adb shell monkey-p package name-v 10 / / default level, providing only a small amount of information such as startup, test completion and final result

Level 1: adb shell monkey-p package name-v-v 10 / / provides a more detailed log, including each event information sent to Activity

Level 2: adb shell monkey-p package name-v-v-v 10 / / provides the most detailed log, including Activity information selected / unselected in the test

1. Program unresponsive: ANR problem: search for "ANR" in the log

two。 Crash problem: search for "CRASH" in the log

3. Other questions: search for "Exception" in the log

9. Simulate user operation

Click event

Adb shell input keyevent

Slide

Adb shell input swipe 300 1000 300 500

Text input

Adb shell input text hello,world

10. Screenshot and video recording:

Adb shell screencap / system/test.png file save path

Adb shell screenrecord file save path

Adb remount remounts the system partition to make it writable or rebooted (http://www.metsky.com/archives/670.html)

Some parameters of screenrecord

-- size width x height sets the resolution eg:1280x720

-- bit-rate rate video bit rate. Default is 4Mbps. You can set 6Mbps for better quality eg:adb shell screenrecord-- bit-rate 6000000 / system/demo.mp4.

-time-limit time sets the maximum recording duration (in seconds). Both the default and maximum values are 180 (3 minutes)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report