ADB simple command and Monkey use

Source: Internet
Author: User

After configuring the Android SDK environment variable, connect the Android phone to your computer and do some simple commands for ADB.

ADB, Android Debug Bridge, one of the tools of the Android™ SDK. Direct operation to manage Android simulator or real Android device.

Use ADB tools to manage the status of your device or phone simulator, and do many phone operations, such as installing software, upgrading your system, running shell commands, and more.

In fact, Jane said, the ADB is connected to the Android phone and PC-side bridge, can let users on the computer on the mobile phone for full operation.

Common commands:

1, adb install path (Computer SDK command directory) install APK

2. View the ADB command Help information:

ADB Help

3, adb uninstall package_name uninstall APK

4. ADB device

5. adb LogCat View Log output

6, ADB shell pm to view the relevant usage of ADB shell pm

7, adb-s devicename serial number

8, enter through the ADB connected to the device, through the following command to view:

>cmd entering the command interface, enter the ADB shell

> then enter the PM list packages to view the package name

Demo Display:

    

9. Check the package name of the mobile app

Input command adb shell PM list Packages

10. Check the package name for the APK path and name

ADB shell PM List packages-f

11. adb Shell Dumpsys List all apk details

12. Get the files in the emulator:

ADB pull <remote> <local>

13. Write the file to the emulator:

ADB push <local> <remote>

14. Enter the shell mode of the simulator:

ADB shell

15. Launch the SDK, documentation, instance download Manager:

Android

16. Unloading APK Package:

ADB shell

CD Data/app

RM APK Package

Exit

The main package name of the ADB uninstall APK package

ADB install-r APK Package

17. View the ADB command Help information:

ADB Help

18. View the log information on the command line:

ADB logcat-s label Signature

The commands behind the ADB shell come mainly from:

SOURCE \system\core\toolbox directory and source code \FRAMEWORKS\BASE\CMDS directory.

20. Remove the System application:

ADB remount (re-mount the system partition so that the system partition is re-writable).

ADB shell

CD System/app

RM *.apk

21. Get Administrator Privileges:

ADB root

22. Start activity:

ADB shell am START-N package Name/package name + class name (-N class name,-a action,-d date,-m mime-type,-c category,-e Extended data, etc.).

23. Release Port:

You can set any port number as the request port for the host to the emulator or device. Such as:
ADB forward tcp:5555 tcp:8000

24. Copy files:

You can copy files to a device or from a device,
To copy a file or directory to a device or emulator:
ADB push <source> <destination></destination></source>
such as: adb push test.txt/tmp/test.txt
To copy a file or directory from a device or emulator:
ADB pull <source> <destination></destination></source>
such as: ADB pull/addroid/lib/libwebcore.so.

25, the Search simulator/device instance:

Gets a list of instances of the currently running emulator/device and the status of each instance:
ADB devices

26. Check the bug report:
ADB bugreport
27. Record the wireless communication log:

Generally speaking, the wireless communication log is very many, at run time not necessary to record, but we can still through the command, set the record:
ADB shell
Logcat-b Radio

28. Get the ID and serial number of the device:

ADB get-product
ADB Get-serialno

29. Accessing the database SQLite3

ADB shell
Sqlite3

#cd system/sd/data//Enter the specified folder within the system
#ls//list displays the contents of the current folder
#rm-R xxx//delete the folder with the name xxx and all the files inside it
#rm XXX//delete file xxx
#rmdir xxx//delete xxx folder

▲ Additional Operation commands

1. View the device

ADB devices

This command is to view the currently connected device, the Android device connected to the computer, or the emulator will list the display

  2. Installing the Software

ADB install

ADB install <apk file path >: This command installs the specified APK file on the device

3. Uninstalling the Software

ADB uninstall < software name >

ADB uninstall-k < software name >

If you add the-K parameter, the software is uninstalled but the configuration and cache files are preserved.

4. Enter the shell of the device or simulator:

ADB shell

From the above command, you can enter the device or emulator shell environment, in this Linux shell, you can execute a variety of Linux commands, in addition, if you want to execute only one shell command, you can use the following way:

ADB Shell [command]

For example, the ADB shell DMESG will print out debug information for the kernel.

5. Publishing ports

You can set any port number as the request port for the host to the emulator or device. Such as:

ADB forward tcp:5555 tcp:8000

6. Send files from the computer to the device

ADB Push < Local path > < remote path >

Use the push command to copy files or folders on your computer to your device (mobile)

7. Download files from the device to the computer

ADB pull < Remote path > < local path >

Use the pull command to copy files or folders on your device (phone) to your local computer

8. View Bug Reports

ADB bugreport

9. Record the wireless communication log

Generally speaking, the wireless communication log is very many, at run time not necessary to record, but we can still through the command, set the record:

ADB shell

Logcat-b Radio

10. Get the ID and serial number of the device

ADB get-product

ADB Get-serialno

ADB shell

Sqlite3

After a simple understanding of the ADB command, first touch the simplest monkey test.

Monkey Common Parameters :

> Connect phone, console input adb shell

> Input Mongkey, the parameters of the Monkey command are displayed

    

> Use the ADB shell PM list packages to view the package name;

>monkey Common parameters

-p Specifies the package name (all commands are executed within this package and executed within the entire system if not specified)

-V Log verbosity (up to-v-v-V)

-S seed (the execution order of the same command at any time and place is the same after the seed is specified)

--throttle single-step delay (per operation interval, in milliseconds)

--kill-process-offer-error Kill Process when error occurs

--ignore-timeouts Ignore timeout errors

--igore-security-exceptions Ignoring license errors

Example:

    

▲ Specify the package name Com.baidu.map.location,log the highest level of detail, then the seed is 12, one step delay of 500ms, the total execution of 1000 steps.

After the-s command has been added, the state of the device must be the same before the command is executed to ensure that the same result is obtained for subsequent commands.

After a simple understanding of the ADB command, first touch the simplest monkey test.

Monkey Common parameters:

> Connect phone, console input adb shell

> Input Mongkey, the parameters of the Monkey command are displayed

    

> Use the ADB shell PM list packages to view the package name;

>monkey Common parameters

-p Specifies the package name (all commands are executed within this package and executed within the entire system if not specified)

-V Log verbosity (up to-v-v-V)

-S seed (the execution order of the same command at any time and place is the same after the seed is specified)

--throttle single-step delay (per operation interval, in milliseconds)

--kill-process-offer-error Kill Process when error occurs

--ignore-timeouts Ignore timeout errors

--igore-security-exceptions Ignoring license errors

Example:

    

▲ Specify the package name Com.baidu.map.location,log the highest level of detail, then the seed is 12, one step delay of 500ms, the total execution of 1000 steps.

After the-s command has been added, the state of the device must be the same before the command is executed to ensure that the same result is obtained for subsequent commands.

ADB simple command and Monkey use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.