adb-- commonly used commands

Foreplay

adb works:

When you start a adb client, the client first checks adb server process already running, if not, it will start the process server when the server starts, it bind the local TCP port 5037 and listens for clients from adb commands sent to all adb clients use port 5037 to communicate with the adb server

Enable debugging adb

To use the USB-connected device adb, you must enable adb debugging device in the system settings (located under Developer Tools), without the developer tools, find the phone, the version number, multiple clicks

God simulator port night there is a pattern: the first simulator port is 62001, the second port is 62025, and the third is 62025 + 1, and so on

adb command

View the version number: directly in the cmd input:

adb version

Connection simulator:

adb connect 127.0.0.1:62001

View simulator connected:

adb devices

Tips:

If the following message appears

adb server version(31) doesn‘t match this client(36)

The reason: adb wrong version, inconsistent versions of the Android SDK and adb version

Solution: replace the Android SDK emulator adb adb can be. Adb simulator path, installation path \ Nox \ bin

shell adb
Android is the underlying linux system, into the character interface linux system

Enter the specified device shell

adb -s 127.0.0.1:62001 shell

Exit adb shell

exit

After entering the adb shell display has two states: # representatives have root privileges, $ representatives not root

Tips:

First To connect the emulator to install and execute commands

In the equipment installation apk

Adb install path to the file (installed by default)

Covering installation

adb install -r file path

Specified equipment installation

adb -s 127.0.0.1:62001 install the file path

Such as the installation encountered an error: Faiture [INSTALL_FAILED_INVALID_URI]

解决方案:cmd命令行下执行以下命令

第一步:adb remount

第二步:adb shell

第三步:cd /data

第四步:chmod 777 local

重新安装apk,ok

卸载app

首先进入设备的/data/app目录找到app包名

adb shell

cd /data/app/

执行命令删除

adb uninstall (-k) 包名

adb uninstall com.wandoujia.phoenix2

要在cmd下执行卸载命令,不是在shell下执行

安装后的包名系统会在末尾加上-1之类的数字,要去掉才可以成功卸载,软件名称为包名,不要包含.apk

-k参数,卸载软件但保留配置和缓冲文件

adb uninstall -k com.wandoujia.phoenix2

查看设备上安装的应用包名

adb shell pm list package

只查找某个包

先进入shell下,在查找

文件读取写入

将文件从pc写入到设备

adb push 电脑文件路径 设备路径

将文件从设备读取到pc

adb pull 设备文件路径 电脑文件路径

注意:由于权限问题,不能直接pull到电脑磁盘根目录,否则会报错

截图

adb shell screencap /sdcard/wandou.png

adb服务启动和关闭

adb kill-server 关闭adb服务

adb start-server 启动adb服务

录屏

adb shell screenrecord /sdcard/demo.mp4

查看包名

aapt dump badging 文件名路径

aapt dump badging F:\App\weixin.apk | findstr "launchable-activity"

没有安装包

使用

adb shell dumpsys window | findstr mCurrentFocus

命令查看当前运行的包名和Activity更清晰一些

 

Guess you like

Origin www.cnblogs.com/zouzou-busy/p/11366799.html