ADB-Android Debug Bridge
,Действует как мост отладки;adb
мы можемEclipse
В меру удобнопроходитьDDMS
для отладкиAndroid
программа;adb
это своего родаклиент、Служить Серверное приложениепрограмма,использоватьCS
Архитектура;adb
Включает в себя три компонента:клиент、демон(adbd
)、сервер.adb
Каталог, в котором он находится, добавляется в переменные системной среды.:android-sdk-windows
,напрямуюplatform-tools
Просто добавьте каталог в переменную системной среды.;D:\android-sdk-windows\platform-tools
adb
См. следующую информацию,иллюстрироватьadb
окружающая средаok
из:C:\Users\Administrator>adb
Android Debug Bridge version 1.0.41
Version 29.0.6-6198805
Installed as D:\android-sdk-windows\platform-tools\adb.exe
global options:
-a listen on all network interfaces, not just localhost
-d use USB device (error if multiple devices connected)
-e use TCP/IP device (error if multiple TCP/IP devices available)
-s SERIAL use device with given serial (overrides $ANDROID_SERIAL)
-t ID use device with given transport id
-H name of adb server host [default=localhost]
-P port of adb server [default=5037]
-L SOCKET listen on given socket for adb server [default=tcp:localhost:5037]
general commands:
devices [-l] list connected devices (-l for long output)
help show this help message
version show version num
networking:
adb
Версия:adb version
adb
Служить:adb start-server
adb
Служить:adb kill-server
adb devices
adb devices
часattached
означает соединениесостояние;
состояние | иллюстрировать |
---|---|
| Офлайн-статус |
| Устройство успешно получено |
| Нет подключенного устройства |
| Нет авторизации |
PC
конец?adb shell
:
sdcard
Создайте новый файл вtest.txt
:
PC
конец:adb pull /sdcard/test.txt .
test.txt
копироватьPC
конецтекущий каталог:
PC
конецтекущий каталог新建一个test01.txt
;adb push test01.txt /sdcard/
adb shell
:
adb shell pm list package
C:\Users\Administrator>adb shell pm list package
package:com.google.android.katniss
package:com.android.providers.telephony
package:com.android.providers.calendar
package:com.android.tv.settings
package:com.lego.android.tvleanback
package:com.android.providers.media
package:com.android.externalstorage
package:com.android.htmlviewer
package:com.android.providers.downloads
package:com.android.providers.tv
package:com.google.android.pano.packageinstaller
package:com.google.android.backdrop
package:com.google.android.configupdater
package:com.android.defcontainer
package:com.android.vending
package:com.android.pacprocessor
package:com.android.certinstaller
package:com.android.carrierconfig
package:com.google.android.marvin.talkback
package:com.google.android.leanback.ime
package:android
package:com.android.backupconfirm
package:com.google.android.tv.remotepairing
package:com.android.statementservice
package:com.google.android.tv
package:com.google.android.gsf.notouch
package:com.android.providers.settings
package:com.android.sharedstoragebackup
package:com.android.printspooler
package:com.android.dreams.basic
package:com.android.inputdevices
package:com.android.backuptester
package:com.android.sdksetup
package:com.google.android.webview
package:com.google.android.syncadapters.contacts
package:com.android.keychain
package:com.android.emulator.smoketests
package:com.google.android.gms
package:com.google.android.gsf
package:com.google.android.sss
package:com.google.android.tts
package:com.android.packageinstaller
package:com.android.proxyhandler
package:com.google.android.tungsten.overscan
package:com.android.netspeed
package:com.google.android.leanbacklauncher
package:com.google.android.backuptransport
package:com.google.android.sss.authbridge
package:com.android.vpndialogs
package:com.android.shell
package:com.android.providers.userdictionary
package:com.android.location.fused
package:com.android.systemui
package:com.android.bluetooth
package:com.android.development
package:com.android.providers.contacts
adb shell pm list package -s
adb shell pm list package -3
adb shell pm list package bluetooth
adb install [-lrtsdg] [--instant] PACKAGE
adb uninstall [-k] PACKAGE
adb shell pm clear <pachagename>
adb shell dumpsys batterystats
C:\Users\Administrator>adb shell dumpsys batterystats
Battery History (0% used, 580 used of 256KB, 5 strings using 322):
0 (9) RESET:TIME: 2023-11-27-06-46-44
0 (2) 050 status=charging health=good plug=ac temp=0 volt=0 +running +plugged +charging
+1s922ms (2) 050 +screen
+1s922ms (3) 050 +wake_lock=-1:"screen" brightness=bright
+1s922ms (2) 050 brightness=medium
+3s504ms (2) 050 +user=0:"0"
+3s504ms (2) 050 +userfg=0:"0"
+3s508ms (3) 050 +audio +top=u0a10:"com.google.android.leanbacklauncher"
+4s586ms (2) 050 -audio
+4s618ms (2) 050 +audio
+4s753ms (2) 050 -audio
+4s793ms (2) 050 +audio
+4s856ms (2) 050 -audio
+5s092ms (2) 050 +audio
+5s133ms (2) 050 -audio
+5s215ms (2) 050 +audio
+5s235ms (2) 050 -audio
+5s500ms (2) 050 +audio
+5s524ms (2) 050 -audio
+5s647ms (2) 050 +audio
+5s949ms (2) 050 -audio
+24s228ms (9) TIME: 2023-11-27-06-47-06
+26s153ms (2) 050 +tmpwhitelist=u0a8:"broadcast:u0a8:com.google.android.intent.action.GCM_RECONNECT"
+41s653ms (2) 050 -tmpwhitelist=u0a8:"broadcast:u0a8:com.google.android.intent.action.GCM_RECONNECT"
+58s370ms (3) 050 brightness=dark +tmpwhitelist=u0a8:"broadcast:u0a8:com.google.android.intent.action.GCM_RECONNECT"
+1m08s425ms (2) 050 -tmpwhitelist=u0a8:"broadcast:u0a8:com.google.android.intent.action.GCM_RECONNECT"
+1m58s462ms (2) 050 +tmpwhitelist=u0a8:"broadcast:u0a8:com.google.android.intent.action.GCM_RECONNECT"
+2m06s262ms (2) 050 brightness=medium
+2m08s519ms (2) 050 -tmpwhitelist=u0a8:"broadcast:u0a8:com.google.android.intent.action.GCM_RECONNECT"
+3m38s536ms (2) 050 +tmpwhitelist=u0a8:"broadcast:u0a8:com.google.android.intent.action.GCM_RECONNECT"
+3m48s600ms (2) 050 -tmpwhitelist=u0a8:"broadcast:u0a8:com.google.android.intent.action.GCM_RECONNECT"
+5m10s201ms (2) 050 brightness=dark
+5m31s586ms (2) 050 brightness=medium
+5m50s977ms (2) 050 -top=u0a10:"com.google.android.leanbacklauncher"
+5m50s977ms (2) 050 +top=1000:"com.android.tv.settings"
+6m18s901ms (2) 050 -top=1
CPU
информация:adb shell dumpsys cpuinfo
C:\Users\Administrator>adb shell dumpsys cpuinfo
Load: 0.22 / 0.07 / 0.06
CPU usage from 704709ms to 682530ms ago:
1.3% 1208/surfaceflinger: 0.1% user + 1.1% kernel
0.9% 1548/system_server: 0% user + 0.9% kernel / faults: 120 minor
0.8% 1248/adbd: 0% user + 0.8% kernel / faults: 439 minor
0% 2140/com.google.android.gms: 0% user + 0% kernel / faults: 844 minor
0% 8/rcu_preempt: 0% user + 0% kernel
0% 1175/kworker/0:1H: 0% user + 0% kernel
0% 1186/logd: 0% user + 0% kernel / faults: 3 minor
0% 1200/healthd: 0% user + 0% kernel
0% 1202/lmkd: 0% user + 0% kernel
0% 1909/com.google.android.gms.persistent: 0% user + 0% kernel / faults: 3 minor
0.8% TOTAL: 0% user + 0.7% kernel + 0% iowait + 0% softirq
adb shell am start -n имя пакета
adb shell logcat путь хранения
adb shell logcat > ./adb_log.txt
уровень | иллюстрировать |
---|---|
| уровеньсамый низкий,Вся информация журнала |
| журнал отладки |
| Общий журнал |
| журнал предупреждений |
| журнал ошибок |
| Самый высокийуровень,Ничего не выводится |
input
Заказ:adb shell input keyevent значение кода ключа
adb shell input swipe x1 y1 x2 y2
adb shell getprop ro.product.model
adb shell wm size
adb shell wm density
adb shell dumpsys window displays
ID
:adb shell settings get secure android_id
adb shell getprop ro.build.version.release
ip
адрес:adb shell ifconfig
adb --help
Проверять:C:\Users\Administrator>adb --help
Android Debug Bridge version 1.0.41
Version 29.0.6-6198805
Installed as D:\android-sdk-windows\platform-tools\adb.exe
global options:
-a listen on all network interfaces, not just localhost
-d use USB device (error if multiple devices connected)
-e use TCP/IP device (error if multiple TCP/IP devices available)
-s SERIAL use device with given serial (overrides $ANDROID_SERIAL)
-t ID use device with given transport id
-H name of adb server host [default=localhost]
-P port of adb server [default=5037]
-L SOCKET listen on given socket for adb server [default=tcp:localhost:5037]
general commands:
devices [-l] list connected devices (-l for long output)
help show this help message
version show version num
networking:
connect HOST[:PORT] connect to a device via TCP/IP
disconnect [[HOST]:PORT] disconnect from given TCP/IP device, or all
forward --list list all forward socket connections
forward [--no-rebind] LOCAL REMOTE
forward socket connection using:
tcp:<port> (<local> may be "tcp:0" to pick any open port)
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
acceptfd:<fd> (listen only)
forward --remove LOCAL remove specific forward socket connection
forward --remove-all remove all forward socket connections
ppp TTY [PARAMETER...] run PPP over USB
reverse --list list all reverse socket connections from device
reverse [--no-rebind] REMOTE LOCAL
reverse socket connection using:
tcp:<port> (<remote> may be "tcp:0" to pick any open port)
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
reverse --remove REMOTE remove specific reverse socket connection
reverse --remove-all remove all reverse socket connections from device
file transfer:
push [--sync] LOCAL... REMOTE
copy local files/directories to device
--sync: only push files that are newer on the host than the device
pull [-a] REMOTE... LOCAL
copy files/dirs from device
-a: preserve file timestamp and mode
sync [all|data|odm|oem|product|system|system_ext|vendor]
sync a local build from $ANDROID_PRODUCT_OUT to the device (default all)
-l: list files that would be copied, but don't copy them
shell:
shell [-e ESCAPE] [-n] [-Tt] [-x] [COMMAND...]
run remote shell command (interactive shell if no command given)
-e: choose escape character, or "none"; default '~'
-n: don't read from stdin
-T: disable pty allocation
-t: allocate a pty if on a tty (-tt: force pty allocation)
-x: disable remote exit codes and stdout/stderr separation
emu COMMAND run emulator console command
app installation (see also `adb shell cmd package help`):
install [-lrtsdg] [--instant] PACKAGE
push a single package to the device and install it
install-multiple [-lrtsdpg] [--instant] PACKAGE...
push multiple APKs to the device for a single package and install them
install-multi-package [-lrtsdpg] [--instant] PACKAGE...
push one or more packages to the device and install them atomically
-r: replace existing application
-t: allow test packages
-d: allow version code downgrade (debuggable packages only)
-p: partial application install (install-multiple only)
-g: grant all runtime permissions
--abi ABI: override platform's default ABI
--instant: cause the app to be installed as an ephemeral install app
--no-streaming: always push APK to device and invoke Package Manager as separate steps
--streaming: force streaming APK directly into Package Manager
--fastdeploy: use fast deploy
--no-fastdeploy: prevent use of fast deploy
--force-agent: force update of deployment agent when using fast deploy
--date-check-agent: update deployment agent when local version is newer and using fast deploy
--version-check-agent: update deployment agent when local version has different version code and using fast deploy
(See also `adb shell pm help` for more options.)
uninstall [-k] PACKAGE
remove this app package from the device
'-k': keep the data and cache directories
debugging:
bugreport [PATH]
write bugreport to given PATH [default=bugreport.zip];
if PATH is a directory, the bug report is saved in that directory.
devices that don't support zipped bug reports output to stdout.
jdwp list pids of processes hosting a JDWP transport
logcat show device log (logcat --help for more)
security:
disable-verity disable dm-verity checking on userdebug builds
enable-verity re-enable dm-verity checking on userdebug builds
keygen FILE
generate adb public/private key; private key stored in FILE,
scripting:
wait-for[-TRANSPORT]-STATE
wait for device to be in the given state
STATE: device, recovery, rescue, sideload, bootloader, or disconnect
TRANSPORT: usb, local, or any [default=any]
get-state print offline | bootloader | device
get-serialno print <serial-number>
get-devpath print <device-path>
remount [-R]
remount partitions read-write. if a reboot is required, -R will
will automatically reboot the device.
reboot [bootloader|recovery|sideload|sideload-auto-reboot]
reboot the device; defaults to booting system image but
supports bootloader and recovery too. sideload reboots
into recovery and automatically starts sideload mode,
sideload-auto-reboot is the same but reboots after sideloading.
sideload OTAPACKAGE sideload the given full OTA package
root restart adbd with root permissions
unroot restart adbd without root permissions
usb restart adbd listening on USB
tcpip PORT restart adbd listening on TCP on PORT
internal debugging:
start-server ensure that there is a server running
kill-server kill the server if it is running
reconnect kick connection from host side to force reconnect
reconnect device kick connection from device side to force reconnect
reconnect offline reset offline/unauthorized devices to force reconnect
environment variables:
$ADB_TRACE
comma-separated list of debug info to log:
all,adb,sockets,packets,rwx,usb,sync,sysdeps,transport,jdwp
$ADB_VENDOR_KEYS colon-separated list of keys (files or directories)
$ANDROID_SERIAL serial number to connect to (see -s)
$ANDROID_LOG_TAGS tags to be used by logcat (see logcat --help)
$ADB_LOCAL_TRANSPORT_MAX_PORT max emulator scan port (default 5585, 16 emus)
ЯсуществоватьучаствоватьНа третьем этапе специального тренировочного лагеря Tencent Technology Creation 2023 года будет проводиться конкурс сочинений. Соберите команду, чтобы выиграть приз!