A. Use the adb LAN function to connect the device
1. Run the adb command with a usb connection and change the connection mode to tcpip.
Adb tcpip {port} port is the port number
2. Unplug the USB cable and run the adb command to connect to the device.
Adb connect xxx. xxx (device ip): port (the port number just set)
3. Run the adb command normally.
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. ADB is a client-server program, where the client is the computer you use to operate and the server is an android device.
B. Some Common commands of adb shell
1. adb shell
A. 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. If you only want to execute one command, you can enter adb shell cmd.
Eg: adb shell dmesg will print the kernel debugging information
Adb shell logcat v prints the log information
B. adb shell ls: list the directories of devices.
Eg: adb device connection operation
Adb shell
Adb-s xxxx shell
2. Upload the file: adb push
Download file: adb pull
/Tmp/... indicates the path of the file to be operated in the linux environment of the device.
Eg: adb push key data/app uploads the key file to the user directory.
A. Put files into the device
Eg: adb push xxx. */directory
Adb-s xxxx (device number) xxx. */directory
B. pulling files out of the device
Eg: adb pull xxx. */directory
Adb-s xxxx (device number) xxx. */directory
3. Installer: adb install <*. apk>
Uninstall software: adb unistall apk (note that the file name is different during the uninstall and installation, for example, adb shell GPSStatus2b2.apk during installation, this apk file is installed in the data/app directory, but when you use uninstall, you must first enter the name of the apk file installed under the data/appdirectory directory in the linux directory. It is found to be com.w.sim.gpsstatus.apk, using adb uninstall com. your SIM. gpsstatus. do not add the apk suffix. Returns the success result to prove that the file is successfully uninstalled ).
A. Use adb to install apk
Eg: adb install xxx.apk
Adb install-s xxxx (device number) xxx.apk multiple devices
B. Uninstall apk with adb
Eg: adb uinstall xxx.apk (the detailed package name and activity name are usually required)
Adb uinstall-s xxxx (device number) xxx.apk multiple devices
In addition, the software installed through adb (*. apk) is in the "/data/app/" directory, so you do not need to specify a path during installation.
You can also directly use the rm command in the directory when uninstalling it.
If multiple devices are running, you must use the-s,-e, or-d parameters to specify the target device when sending commands.
Adb-e sends commands to the simulator.
Adb-d sends commands to USB devices, such as mobile phones.
Adb-s specifies a target. Adb-s <serialNumber> <command> install <path-to-apk>
Example: adb-s emulator-5554 install helloWorld.apk
4. display the android simulator status:
Adb devices list all connected devices
For example:
~ $ Sudo/opt/Android-SDK/tools/ADB Devices
List of devices attached
Emulator-5554 Device
Ht95lkf00945 Device
Two devices are listed here. The first is the simulator and the second is the mobile phone.
Note: the root user is used to start the ADB server and execute the ADB command. Otherwise, "No permissions" appears"
ADB get-serialno Print Device serial number
ADB version: list the version numbers of ADB.
The output of adb get-state is usually offline | bootloader | device
Adb help view all commands supported by adb
View adb version serial number
Adb logcat prints logs to the screen
Adb bugreport print dumpsys, dumpstate and logcat data to the screen
Adb jdwp view available JDWP information of the specified facility.
Adb forward <local> <remote>
Adb get-serialno view the serial number of the adb instance.
Adb get-state to view the current status of the simulator/facility.
Adb ppp runs PPP through the use Device
Adb wait-for-device will not be executed if the device is offline.
5. device waiting for running: adb wait-for-device
6. adb start-server
Adb kill-server is usually used when the adb shell command is entered to display device offline or multiple devices are displayed.
7. The system partition is remounted as writable by adb remount.
8. adb root administrator privilege
9. adb bugreport: print all bug information
10. adb shell logcat-B radio records wireless communication logs: Generally, there are many wireless communication logs and there is no need to record them during operation. However, you can set the record through the command:
11. adb emu
12. port forwarding: adb forward tcp: 5555 tcp: 1234
(Forward the default port TCP 5555 to port 1234)