Linux / Windows Subsystem for Linux (WSL) 安装 ADB (Android Debug Bridge,Android 调试桥)

幸经艺
2023-12-01

Linux / Windows Subsystem for Linux (WSL) 安装 ADB (Android Debug Bridge,Android 调试桥)

Android 开发者网站
https://developer.android.google.cn/

Android Studio
https://developer.android.google.cn/studio

新变化
https://developer.android.google.cn/studio/features

SDK Platform Tools
https://developer.android.google.cn/studio/releases/platform-tools

Android Debug Bridge,Android 调试桥
https://developer.android.com/studio/command-line/adb

The Android Debug Bridge (adb) is a programming tool used for the debugging of Android-based devices. The daemon on the Android device connects with the server on the host PC over USB or TCP, which connects to the client that is used by the end-user over TCP.

Windows Subsystem for Linux (WSL) is a compatibility layer for running Linux binary executables (in ELF format) natively on Windows 10, Windows 11, and Windows Server 2019.

0. 查看 Linux / Windows Subsystem for Linux (WSL) 系统是否安装 ADB

(base) yongqiang@yongqiang:~$ adb

Command 'adb' not found, but can be installed with:

sudo apt install adb

(base) yongqiang@yongqiang:~$

1. ADB 历史版本下载

Android SDK Platform Tools for Windows, Linux, Mac (all versions) - 历史版本下载
https://androidmtk.com/download-android-sdk-platform-tools

wget https://dl.google.com/android/repository/platform-tools_r30.0.4-linux.zip && unzip platform-tools_r30.0.4-linux.zip

(base) yongqiang@yongqiang:~$ cd software/
(base) yongqiang@yongqiang:~/software$ wget https://dl.google.com/android/repository/platform-tools_r30.0.4-linux.zip && unzip platform-tools_r30.0.4-linux.zip
...
(base) yongqiang@yongqiang:~/software$ ls -l
total 120988
-rwxr-xr-x 1 yongqiang yongqiang 66709754 Jul 22  2021 Miniconda3-latest-Linux-x86_64.sh
-rwxr-xr-x 1 yongqiang yongqiang 47611219 Aug 30  2021 bazel-4.2.1-installer-linux-x86_64.sh
drwxr-xr-x 1 yongqiang yongqiang      512 Apr 30 21:08 platform-tools
-rw-r--r-- 1 yongqiang yongqiang  9542280 Jul 31  2020 platform-tools_r30.0.4-linux.zip
(base) yongqiang@yongqiang:~/software$
(base) yongqiang@yongqiang:~/software$ cd platform-tools/
(base) yongqiang@yongqiang:~/software/platform-tools$ ls -l
total 17408
-rw-rw---- 1 yongqiang yongqiang  362313 Jul 17  2020 NOTICE.txt
-rwxrwxr-x 1 yongqiang yongqiang 7240408 Jul 17  2020 adb
drwxrwx--- 1 yongqiang yongqiang     512 Jul 17  2020 api
-rwxrwxr-x 1 yongqiang yongqiang   59624 Jul 17  2020 dmtracedump
-rwxrwxr-x 1 yongqiang yongqiang 1587192 Jul 17  2020 e2fsdroid
-rwxrwxr-x 1 yongqiang yongqiang  309840 Jul 17  2020 etc1tool
-rwxrwxr-x 1 yongqiang yongqiang 1946232 Jul 17  2020 fastboot
-rwxrwxr-x 1 yongqiang yongqiang   13648 Jul 17  2020 hprof-conv
drwxrwx--- 1 yongqiang yongqiang     512 Jul 17  2020 lib64
-rwxrwxr-x 1 yongqiang yongqiang  254456 Jul 17  2020 make_f2fs
-rwxrwxr-x 1 yongqiang yongqiang  871544 Jul 17  2020 mke2fs
-rwxrwxr-x 1 yongqiang yongqiang    1157 Jul 17  2020 mke2fs.conf
-rwxrwxr-x 1 yongqiang yongqiang 1538336 Jul 17  2020 sload_f2fs
-rw-rw-r-- 1 yongqiang yongqiang      38 Jul 17  2020 source.properties
-rwxrwxr-x 1 yongqiang yongqiang 1366560 Jul 17  2020 sqlite3
drwxrwx--- 1 yongqiang yongqiang     512 Jul 17  2020 systrace
(base) yongqiang@yongqiang:~/software/platform-tools$
(base) yongqiang@yongqiang:~/software/platform-tools$ pwd
/home/yongqiang/software/platform-tools
(base) yongqiang@yongqiang:~/software/platform-tools$
Android Debug Bridge,ADB:Android 调试桥

2. 设置 Linux / Windows Subsystem for Linux (WSL) 环境变量

(base) yongqiang@yongqiang:~$ vim ~/.bashrc
...
# platform-tools_r30.0.4-linux.zip
export PATH="${PATH}:/home/yongqiang/software/platform-tools/"
...
(base) yongqiang@yongqiang:~$ cat ~/.bashrc
...
# platform-tools_r30.0.4-linux.zip
export PATH="${PATH}:/home/yongqiang/software/platform-tools/"
...
(base) yongqiang@yongqiang:~$ source ~/.bashrc

3. 查看 Linux / Windows Subsystem for Linux (WSL) 系统是否成功安装 ADB

(base) yongqiang@yongqiang:~$ adb version
Android Debug Bridge version 1.0.41
Version 30.0.4-6686687
Installed as /home/yongqiang/software/platform-tools/adb
(base) yongqiang@yongqiang:~$
(base) yongqiang@yongqiang:~$ adb shell
HWDUK:/ $ cd /data/local/tmp/
HWDUK:/data/local/tmp $ ls -l
total 0
HWDUK:/data/local/tmp $ exit
(base) yongqiang@yongqiang:~$

4. Windows 启动 adb server

C:\Users\cheng>adb version
Android Debug Bridge version 1.0.41
Version 30.0.4-6686687
Installed as D:\Program Files\platform-tools\adb.exe

C:\Users\cheng>
C:\Users\cheng>adb devices
List of devices attached
FFKDU17A28006357        device


C:\Users\cheng>
C:\Users\cheng>adb -a nodaemon server
adb F 08-29 18:13:43 14532 12896 main.cpp:153] could not install *smartsocket* listener: cannot bind to 0.0.0.0:5037: 閫氬父姣忎釜濂楁帴瀛楀湴鍧€(鍗忚/缃戠粶鍦板潃/绔彛)鍙厑璁镐娇鐢ㄤ竴娆°€?(10048)

C:\Users\cheng>
C:\Users\cheng>adb kill-server

C:\Users\cheng>
C:\Users\cheng>adb -a nodaemon server
adb I 04-30 19:53:44 15496 12640 auth.cpp:417] adb_auth_init...
adb I 04-30 19:53:44 15496 12640 auth.cpp:152] loaded new key from 'C:\Users\cheng\.android\adbkey' with fingerprint C003CF5AD89F690A49BB31A1FB606378F31F0772F9ED77D67B67921478710B0E
adb I 04-30 19:53:44 15496 10268 transport.cpp:325] FFKDU17A28006357: read thread spawning
adb I 04-30 19:53:44 15496 13656 transport.cpp:297] FFKDU17A28006357: write thread spawning
adb I 04-30 19:53:44 15496 12640 transport.cpp:1527] fetching keys for transport FFKDU17A28006357
adb I 04-30 19:53:44 15496 12640 auth.cpp:469] Calling send_auth_response
adb I 04-30 19:53:44 15496 12640 adb.cpp:124] FFKDU17A28006357: offline

5. Linux / Windows Subsystem for Linux (WSL) 连接 devices

(base) yongqiang@yongqiang:~$ adb -H 192.168.0.109 devices
List of devices attached
FFKDU17A28006357        device

(base) yongqiang@yongqiang:~$
(base) yongqiang@yongqiang:~$ adb -H 192.168.0.109 shell
HWDUK:/ $ cd /data/local/tmp/
HWDUK:/data/local/tmp $ ls -l
total 0
HWDUK:/data/local/tmp $ exit
(base) yongqiang@yongqiang:~$

References

https://yongqiang.blog.csdn.net/
https://adbshell.com/

 类似资料: