Android commonly used adb shell commands, androidadb

Source: Internet
Author: User

Android commonly used adb shell commands, androidadb

Debugging Android programs sometimes requires the adb shell command. adb stands for Android Debug Bridge, which serves as the debugging Bridge. Through adb, We can debug the Android program through DDMS in Eclipse. To put it bluntly, it is the debug tool. Adb listens to Socket TCP 5554 and other ports to allow the IDE to communicate with Qemu. By default, the adb process runs automatically when Eclipse is run. Adb is a C/S program consisting of three parts: a client, a server and a daemon. The client and server run on the development machine, and the daemon runs on the emulator or device.
Adb is generally located in the <sdk>/platform-tools/directory, where <sdk> is the installation directory of android sdk. You can add the adb path to the path of the system environment variable, for example, D: \ sdk \ platform-tools. In this way, the adb command can be responded when powershell is enabled, you do not need to enter the adb directory every time. The following are common adb commands:

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

30. cd system/sd/data // enter the specified folder in the system

31. ls // the contents of the current folder are displayed in the list.

32. rm-r xxx // Delete the folder named xxx and all files in it

33. rm xxx // delete file xxx

34. rmdir xxx // Delete the xxx folder


How to Use the adb shell command to obtain the current android activity

(1) run the "adb shell dumpsys activity" command to view
(2) You can also use "adb logcat | grep ActivityManager" to view the currently running Activity.

How to execute the adb command in an android Application

The ADB interface is mainly used to allow computers and other devices to control the Android system. Therefore, it is called "Intermediate bridge ";
It is not used by Android, but can be directly executed as SHELL, which has nothing to do with ADB.
Therefore, Android JAVA does not necessarily have encapsulated ADB classes. There are ADB service programs on the computer, port 5037,
It is an intermediate program that communicates with Daemon on the Android system.
If you want to execute the adb command on your mobile phone, you should directly follow the daemon process
(Daemon) communication. The methods that Baidu can find are not satisfactory.

The landlord uses exec to execute the CMD command. This is no longer an ADB interface. This is the SHELL of the system !!!

I do not know the effect of directly sending commands using socket/tcp. The address is 127.0.0.1, and the port of the android daemon process is used.
5555 is the start of an odd number.
... . Baidu can find the ADB dialog protocol. We recommend you try it.

The upstairs actually requires SHELL, not ADB. I found an article, but I have not tried it,
Do you need ROOT? I don't know. Attach it. Please try again.
If you are satisfied, you can adopt it!



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.