Android11 in AS cooperates with ADB (Android Debug Bridge) for Android development wireless debugging Xiaobai groping process

Disclaimer: Since I have just contacted Android development, if there is anything wrong with the description in the article, please forgive me and let me know.

Preface

With the release of Android 11, Google has improved the wireless debugging function of Android 10 and below, which can only use a data cable to connect to the computer and then perform wireless debugging. Real and wireless debugging can be carried out in Android11 ! (Although It does not seem to be difficult to achieve...) No thread is spent from start to finish! The power adapter is finally no longer alone! ( And Apple has no longer had this trouble since the launch of the 12 series )

The importance of wireless debugging for some people (me)

  1. The laptop has only one USB port, and the docking station is often exhausted (again, the designer complains)
  2. Virtual machine cannot run due to computer configuration
  3. The desire to develop apps based on personal touch (not the mouse)
  4. Based on the desire to quickly deploy to your own mobile phone and easily touch your own apps anytime, anywhere
  5. Multiple Android devices can be deployed

Must-have list

  1. A smartphone with confirmed Android version 11
  2. The Android SDK tool on the computer needs to be version ≥ 30.0.0, confirmation method: win+ REnter cmd and press enter adb --version The result is as follows:
adb --version
Android Debug Bridge version 1.0.41
Version 30.0.5-6877874
Installed as D:\Android\SDK\platform-tools\adb.exe
  1. Connect your phone and computer under the same WIFI
  2. Enable the developer mode on the mobile phone (usually about the mobile phone --> continuously click the version number until you are prompted to enter the developer mode);
  3. Enable ADB debugging and wireless debugging options in the developer options menu.
  4. In the dialog box asking Do you want to allow wireless debugging on this network?, click Allow. You can see the pairing code, ip and port number (see picture for details)
    5
    6

method one

This method comes from the Android developer documentation

Run adb pair ipaddr:port. Using the IP address and port number in step 6, the result is as follows.

~ » adb pair 192.168.25.25:37815
Enter pairing code: 364531 // 输入在 步骤6 中获取到的配对码
Successfully paired to 192.168.25.25:37815 [guid=adb-05KAY1XPBC-hyXNZI]

When prompted, enter the pairing code you obtained in step 6. A message will show that your device has been successfully paired.

Before issuing the adb command, it is helpful to know which devices are connected to the adb server. You can use the devices command to generate a list of connected devices. as follows:

$ adb devices -l
List of devices attached
emulator-5556 device product:sdk_google_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64
emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86
0a388e93      device usb:1-1 product:razor model:Nexus_7 device:flo

It can be seen that two emulators and a Nexus have been successfully connected. For the
rest of the operation, please refer to the Android developer documentation.
Note : At this step, my device connection list is empty. In order to solve this problem, there is a second method.

Method Two

This method uses the AS plug-in ADB WiFi, thank you the developer for saving my life
  1. Follow step 6 of the list to obtain the IP address of the Android device
  2. In Android Studio, click File-->Settings-->Plugins-->Marketplace to search for the plug-in ADB WIFI and click Install to install
  3. After the plug-in installation is complete, click File–>Settings–>OtherSettings–>ADB WIFI, and change the default adb.exe path to the custom path when installing the SDK, and the path should go to the platform-tools folder in the SDK folder.
    3
  4. Click ADB WIFI in the right sidebar of this page, and then click + in the upper left corner
    4
  5. After the above steps are completed, enter the device IP address in this input box, paying attention not to include the port number. After the input is complete, click Connect
    5
  6. The status after successful connection is as shown below
    6
  7. Just replace the test device with a connected device
    7

Guess you like

Origin blog.csdn.net/weixin_42827253/article/details/112987073