ADB (Android Debug Bridge) is a tool in the Android SDK that needs to be configured with environment variables before it can be used. The role of the Debug bridge, you can manage the Android device. (also called Debug tool)
---------View Device Connection status-----------
adb get-serialno get the ID and serial number of the device <serialNumber>
ADB devices queries the devices connected to the current computer (including simulators and phones)
adb get-state View the current status of the simulator/facility.
----------send commands to the device-----------
adb [-d|-e|-s <serialnumber>] <command>
-d Send command to USB connected device
-e Send command to emulator device
-S <serialNumber> send command to specified device
If you start your mobile device shell:adb-d shell
adb forward <local> <remote> release port, you can set any port number as the host to the emulator or device request port. such as: adb forward tcp:5555 tcp:8000
adb bugreport output bug Log
adb reboot Restart your phone
adb remount to re-mount the system partition as a read-write partition
adb kill-server terminates adb service process
adb start-server restart ADB service process
adb root has root access to restart ADB service
adb wait-for-device commands are reproduced in the ADB command before the simulator/device is connected
adb jdwp View the available jdwp information for the specified facility.
adb shell am command to start the application
adb shell input text <string> input text to device (the text box where the cursor is located)
adb shell input keyevent <event_code> Send key events to the device
For example, when you are editing a text message, enter it into the text box: adb shell input text "Hello"
Send key value back to phone home:adb shell input keyevent 3
Refer to keycode_* in View/keyevent.java
public static final int keycode_soft_left = 1;
public static final int keycode_soft_right = 2;
public static final int keycode_home = 3;
public static final int keycode_back = 4;
public static final int keycode_call = 5;
public static final int keycode_endcall = 6;
Loading and unloading---------------------safety
adb install [-l] [-r] <package> installation application (-L means lock the program; -R Reinstall the app)
adb Uninstall [-K] <package> Uninstall application (-K means not to delete data and cache directories generated by program run)
For example: adb install d:\hello.apk (the system installer in the device is typically "adb install-r apk path")
ADB uninstall Com.google.android.youtube
----------File Operation-----------
adb push <local> <remote> place local files on (copy) target device
adb pull <remote> <local> drag (copy) files from the device to the specified local directory
----------basic Linux shell commands ----------
ADB shell [command] (exit out of adb shell)
ls [-a] [-l] lists the files and folders under the directory (-a indicates that all files are listed, including hidden files; -L indicates list form and all permissions are displayed)
CD Switch directory (CD: Indicates that the upper directory is returned and the theory can be executed multiple times: )
pwd View your current location
mkdir New Folder
Touch New file (can be created multiple times, such as Touch a.txt b.txt .....) )
CP Copy File
mv cut/rename file (rename mv Old-name.txt new-name.txt)
RM Delete directories and files (rmdir can only delete empty folders)
Find File or folder (Find-name file-name; find *a* Fuzzy Lookup)
Cat View file contents
PS can see that process and then run
ps-x [PID] View the status of a single process
Top can see the highest occupancy rate for that process.
su switches to the root user
Kill [PID] kills a process
chmod 777 <file> Modify this file as executable permission (highest privilege)
----------View system Status and information-----------
adb shell Procrank queries the memory usage of each process
adb Shell Service List View services Information
adb shell cat/proc/meminfo view current memory conditions
adb shell cat/proc/cpuinfo View CPU information (hardware)
adb shell cat/proc/iomem view IO memory partition
adb shell getprop lists all system Properties
adb shell Getprop | findstr "GSM" lists the properties that contain GSM
adb shell SetProp <key> <value> Modify System Properties
adb shell sqlite3 can execute SQL statements to view database information.
adb shell dmesg query kernel buffer information
adb shell dumpstate Various kinds of information, such as process information, memory information, process is abnormal, kernnel log, etc.
ADB shell dumpcrash view Crash
adb shell Dumpsys viewing system
adb shell Service queries the status of all service
-----------The Logcat command----------
adb logcat [<option>] [<filter-spec>] view device log.
adb logcat-c clearing log information
ADB logcat-d
1. View the available log buffers:
ADB logcat-b Radio -View the related buffer information for the wireless/phone.
adb logcat-b Events-View the buffer associated with the event.
adb logcat-b Main-View the primary log buffer
2. Filter the log output:
Filter statements in the following format tag[:p riority], tag is component (* refers to all), priority is the rating of the report that represents the tag (precedence)
adb logcat *:w display log information with priority warning or higher
ADB logcat activitymanager:i Myapp:d *:s
Priority is ordered from low to High:
V-verbose (lowest priority, detail)
D-debug (Debug)
I-info (information)
W-warning (Warning)
E-error (Error)
F-fatal (Deadly)
S-silent (highest priority, no record)
3. Control log Output format:
Information about the formatted output log can be obtained through the-v option.
[ADB] logcat [-v <format>]
brief -Show priority/label and PID of the original process (default format)
process-show PID only
tag -show priority/Tag
thread-show processes: threads and priorities/tags
Raw -Displays raw log messages with no other metadata fields
Time-Display date, call duration, priority PID
Long -Displays all metadata fields and separates message contents with blank lines
For example:adb logcat-v thread
-----------Other----------
Waiting .....
Detailed android ADB commands