[Android] common android ADB commands

Source: Internet
Author: User

Part 1:

1. Configure the environment anroid variable in Ubuntu:

Run sudo gedit/etc/profile on the terminal to open the text editor and append # Set Android Environment

2. To run eclipse, you also need to configure Java environment variables.

# Set Java environment

Java_home =/home/loginname/JDK directory name

Jre_home =/home/loginname/JDK directory name/JRE

Export Path = $ java_home/bin: $ jre_home/bin: $ path

Export classpath = $ java_home/lib: $ jre_home/lib: $ classpath

Export Path =/home/loginname/android-sdk-linux_86/tools: $ path

After saving, restart

3. Add the device ID to the current Android debugging environment

Add the device ID of the android terminal to the/home/loginname/. Android file.

4. Update the SDK

[Android update SDK] updates the SDK.

5. Common commands:

[ADB help] get help

[ADB get-serialno] Get the device serial number

[ADB root] obtaining root permissions is useful for some mobile phones. Most listed mobile phones have disabled this function. You can also obtain the root permission through a third-party tool such as the bean clip.

[ADB kill-server] kills the server process of ADB.

[ADB start-server] starts the server process of ADB.

[ADB devices] view the android terminal that establishes the connection.

[Android list] displays all android Terminals

[Ddms] Start ddms

ADB remount: Reload the hard disk.

[ADB reboot] restarts the terminal.

[ADB install/path/appname] install the applicationProgram

[ADB uninstall com. Android. helloworld] uninstall helloworld. Applications in the system cannot be uninstalled.

[ADB push/sourcepath/filename/destinationpath/filename] copy a file from the PC end to the terminal

[ADB pull/sourcepath/filename/destinationpath/filename] copy a file from the terminal to the PC end

[ADB logcat-V Time-s tagname] displays the custom tagname and time

[Adb ppp] Start PPP through USB

[ADB monkey-P/path/appname-V 100] forcibly tests the program for 100 times.

ADB shell: Start the shell command terminal on the PC.

The preceding Command requires the root permission on the PC. If the command fails, you can try to switch the working directory to the SDK tools, for example, sudo. /ADB kill-server, sudo. /ADB start-server.

6. Use the following command in shell:

[Am start-N {package name}/{package name}. {activity name}] Start the activity of an app. For configuration reference, see androidmanifest. XML, for example, alarm:
# Am start-N com. Android. alarmclock/COM. Android. alarmclock. alarmclock

[AM broadcast-A Android. Intent. Action. actionname] sends a broadcast message.

Setprop key value: Set the property value of the key.

[Getprop key] Get the property value of this key

[Getevent] get all events

[Watchprops] monitors changes in the property value.

[Stop server] forcibly stops a service

[Start server] starts a service.

[IOCTL] Control Device

Dumpsys activity: displays activity stack information.

[Top] displays the resource usage and other information of instantaneous processes.

[Free] displays the memory usage of the current process.

[PS] displays the identity information of a process.

Rm/path/filename: delete an object from the terminal.

[Mkdir] create a directory or file

[Grep] search for specific content

[Ls] displays files in the current directory

[Cd] switch the current directory

[Chmod] change file attributes

[Cp] copy an object

[DD] copy an object

[MV] Move or rename a directory file

[Cat] View File Content

[Kill] kills the process

[Ipconfig] view and change the network interface address and Parameters

[Ping] checks the network status

[Netstat] view the network status

Telnet

[Sqlite3/path/databasename. dB] Open a database. Then you can use database operation commands such as select, insert, and delete.

[Tcpdump-p-Nnn-vvv-S 0-W/path/name. pcap port 80 and TCP] network debugging packet capture

[GST-launch playbin uri = file: // system/Media/Audio/bootaudioaudio] GST Multimedia Framework for playing audio files

[Alsa_amixer] Audio debugging command. You can switch audio channels, adjust the volume, and switch devices. Different chip manufacturers have different parameter settings.

[Alsa_aplay-D androidplayback_speaker_normal/Cache/music/dial/0.wav] Play the PCM code stream through ALSA.

[Alsa_arecord] recording through ALSA

[Am start-N com. Android. Music/COM. Android. Music. mediaplaybackactivity-D/sdcard/bootaudiolistener] Start the android process to play MP3

[Stack -- symbols-Dir =./out/target/product/name/Symbols ramdump] view the call stack

[Exit] exit Shell

Using ADB shell, CD/system/bin, ls can list most of the available commands.

7. venderid of Some Android phones

#0x0525 NXP Chip

#0x18d1 broadcom2457 dual-card chip

#0x2314 ght Moke

#0x04e8 anycall GT-I5508

#0x22b8 Moto xt701 xt300

#0x0bb4 HTC a8180

 

Part 2:

ADB (Android debug Bridge) is a common tool for Android users. With this tool, we can develop very well. adb.exe is under the android SDK tools directory you have installed,

ADB usage:

ADB [-d |-E |-S <serialnumber>] <command>

When you issue a command, the system enables the android client. The client is not related to the simulator instance, so if the dual server/device is running, you need to use the-D option to determine the target instance for the command to be controlled. For more information about using this option, you can view the terms control commands of the simulator/device instance.

1. Install the application to the simulator:

You can use ADB to copy an application from your development computer and install it on a simulator/device instance. Run the install command. This installcommand requires you to specify the path of the .apk file you want to install:
ADB install <path_to_apk>
For more information about how to create a .apk file that can be installed on the simulator/device, see Android asset packaging tool (aapt ).
Note that if you are using Eclipse IDE and have installed the ADT plug-in, you do not need to directly use ADB (or aapt) to install the application on the simulator/device. Otherwise, the ADT plug-in handles application packaging and installation on your behalf.
To delete an application, follow these steps, for example, test:
ADB Shell
CD/data/APP
Rm test.apk

2. Enter the shell of the device or simulator:

ADB Shell
Through the above command, you can enter the shell environment of the device or simulator. In this Linux Shell, You can execute various Linux commands. In addition, if you only want to execute one shell command, you can use the following methods:
ADB shell [command]
For example, ADB shell dmesg prints the kernel debugging information.

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

4. Import or copy files from the simulator/device:

You can use the adbpull and push commands to copy files to or from a data file of a simulator/device instance. The installcommand only copies a .apk file to a specific location. Different from the command, the pull and push commands allow you to copy arbitrary directories and files to any location of a simulator/device instance.
Copy a file or directory from a simulator or device and use the following command ):
ADB pull <remote> <local>
Copy the file or directory to the simulator or device and run the following command)
ADB push <local> <remote>
In these commands, <local> and <remote> indicate the path to the target file/directory on the development machine (local) and simulator/device instance (remote) respectively.
The following is an example:
ADB push test.txt/data/DAT/test/test.txt,

5. query Simulators/device instances:

Before releasing the ADB command, it is necessary to know what kind of simulator/device instance is connected to the ADB server. You can use devices
Command to obtain a series of associated Simulators/devices:
ADB Devices

In response, ADB develops the corresponding status information for each instance:
Serial number-a string created by ADB, which uniquely identifies a simulator/device instance through its own control port <type>-<consoleport>.
The following is an example of a serial number:
Emulator-5554
There are three instance connection statuses:
Offline-this instance is not connected to ADB or cannot respond.
Device-this instance is connected to the ADB server. Note that this status does not indicate that the system is running and operating the Android system. Therefore, this instance is connected to ADB when the system is running. However, after the system is started, it is a normal running status of the simulator/device.
The output format of each instance is fixed as follows:
[Serialnumber] [State]
The following is an example of the devices command and output:
$ ADB Devices
List of devices attached
Emulator-5554 Device
Emulator-5556 Device
Emulator-5558 Device

If no simulator/device is running, ADB returns no device.

6. view the bug report:

ADB bugreport

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

8. Get the device ID and serial number:

ADB get-Product
ADB get-serialno

9. Access the database sqlite3

ADB Shell
Sqlite3

To open an existing database:

Sqlite3 <path>/dbname. DB

 

Original article address:

Http://blog.csdn.net/cubuntu/article/details/6727623

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.