ADB shell command

Source: Internet
Author: User
Tags linux shell commands

Generally, the ADB shell command is used during development. In my personal development, apart from some ADB commands, in fact, the basic commands of Linux are also very important, especially during terminal debugging. The development environment is connected to the serial port. It is also very useful and necessary to debug Linux commands on the serial port terminal. For example, the CP and RM commands can be used to install and delete an APK installation package.

Below are some common commands of ADB:

 

ADB Introduction

The tools folder of the SDK contains the android simulator operation's Important Command ADB, which is fully called (Android debug bridge is the function of debugging bridge. Through ADB, We can debug Android through ddms in eclipse.Program. With this tool, we can manage the status of devices or mobile phone simulators. You can also perform the following operations:

1. quickly update devices or mobile phone SimulatorsCodeSuch as application or Android system upgrade;
2. Run shell commands on the device;
3. Manage the ports on the device or mobile phone simulator;
4. Copy or paste files on the device or mobile phone simulator;

 

ADB's work in the integrated development environment
ADB works in a special way by listening to socket TCP 5554 and other ports to allow the IDE to communicate with qemu. By default, ADB will use the network port related to daemon, so when we run eclipse, the ADB process will automatically run.
1. You can use ADB to easily execute Linux shell commands. For example, ADB shell DIR is used to list directories. in Linux, the root directory is a drive C and drive D instead of a drive D on Windows.
2. Install the APK program to the simulator and run ADB install android123.apk. The installation package named android123will be installed in the androidsimulator. The preceding file is the android123.apk file which needs to be placed in the SDK/tools directory.
3. transfer the file to emulator. Use the ADB push android123.txt/tmp/android123.txt command to transfer the android123.txt file under SDK/toolsto the/tmp/folder of the simulator, note that the content in the/tmp/folder will be cleared when the android simulator restarts.
4. Returning files from the android simulator to the computer
You can use the ADB pull/tmp/android123.txt android123.txtcommand to upload the android123.txt file from the tmpfile of the simulator to the computer SDK/tools directory.

ADB Common commands

1. display all android platforms in the system:

Android list targets

2. Display All AVD (simulators) in the system ):

Android list AVD

3. Create an AVD (simulator ):

Android create AVD -- name -- Target Platform ID

4. Start the simulator:

Emulator-AVD name-sdcard ~ /Name. IMG (-skin 1280x800)

5. Delete AVD (simulator ):

Android Delete AVD -- name

6. Create an sdcard:

Mksdcard 1024 M ~ /Name. img

7. AVD (simulator) Location:

Linux (~ /. Android/AVD) Windows (C: \ Documents ents and Settings \ Administrator \. Android \ AVD)

8. Start ddms:

Ddms

9. display all currently running simulators:

ADB Devices

10. Run the following command on a simulator:

Abd-s simulator serial number command

11. Install the application:

ADB install-R application .apk

12. Get the files in the simulator:

ADB pull <remote> <local>

13. Write a file to the simulator:

ADB push <local> <remote>

14. Enter the shell mode of the simulator:

ADB Shell

15. Start the SDK, documentation, and instance Download Manager:

Android

16. Upload the APK package:

ADB Shell

CD Data/APP

Rm APK package

Exit

ADB uninstall APK package MAIN package name

ADB install-r APK package

17. view the ADB Command help information:

ADB help

18. view log information in the command line:

ADB logcat-s label name

19. The commands followed by the ADB shell mainly come from:

Source code \ System \ core \ toolbox directory and source code \ frameworks \ base \ cmds directory.

20. delete system applications:

ADB remount (re-mount the system partition to make the system partition writable ).

ADB Shell

CD system/APP

RM *. APK

21. Get administrator permissions:

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 ).

23. Release Port:

You can set any port number as the request port from the host to the simulator or device. For example:
ADB forward TCP: 5555 TCP: 8000

24. copy a file:

You can copy files to or from a device,
Copy a file or directory to the device or simulator:
 ADB push <source> <destination> </source>
Example: ADB push test.txt/tmp/test.txt
Copy a file or directory from a device or simulator:
ADB pull <source> <destination> </source>
For example, ADB pull/addroid/lib/libwebcore. So.

25. Search for simulator/device instances:

Obtain the list of running Simulators/devices and the status of each instance:
ADB Devices

26. view the bug report:
ADB bugreport
27. Record wireless communication logs:

In general, there are a lot of wireless communication logs and there is no need to record them during operation, but we can still set the record through the command:
ADB Shell
Logcat-B radio

28. Obtain the device ID and serial number:

ADB get-Product
ADB get-serialno

29. Access the database sqlite3

ADB Shell
Sqlite3

# Cd system/SD/Data // enter the specified folder in the system
# Ls // the contents of the current folder are displayed in the list
# Rm-r XXX // delete a folder named XXX and all its files
# Rm XXX // delete file xxx
# Rmdir XXX // Delete the xxx folder

Related Article

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.