Development environment:

Computer: Mac Mini console

Development tools: DevEco Studio 2.1 Beta4

Third-party software: Scrcpy Android-platform-tools

1. First check whether the computer has BREW installed

Army-mac-mini-2 :~ Army $brew-v Homebrew 3.1.5 Homebrew/ Homebrew-core (Git Revision 4C638b0758; last commit 2021-04-30) Homebrew/homebrew-cask (git revision bdb866f4fc; last commit 2021-04-30)Copy the code

If not, execute the following installation command:

Army-Mac-mini-2:~ army$ /usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install)"
Copy the code

2. Install the Scrcpy Android-platform-tools software

Army-Mac-mini-2:~ army$  brew install scrcpy
Army-Mac-mini-2:~ army$  brew install --cask android-platform-tools
Copy the code

3. Ensure that the PC and mobile phone are connected to the same Wifi

4. Connect the mobile phone to the PC through USB first

5. Run the ADB tcpIP service port on the PC, for example, port 6666

First check what devices are on the computer

Army-Mac-mini-2:~ army$  adb devices
List of devices attached
XIU0220C17029368	device
Copy the code

Open service port 6666

Army-Mac-mini-2:~ army$  adb -s XIU0220C17029368 tcpip 6666
Copy the code

6. Unplug your device and disconnect the USB connection

7. Run ADB Connect mobile IP: service port on PC

Army-mac-mini-2 :~ Army $adb Connect 192.168.3.168:6666Copy the code

8. Connect to the mobile phone using the mobile phone IP address + service port number

Army-Mac-mini-2:~ army$  scrcpy -s 192.168.3.168:6666
Copy the code

9. Generate a debugging certificate. For details, see the official documentation

Developer.harmonyos.com/cn/docs/doc…

10. If the PC is connected to multiple devices, disconnect other connected devices before running the command to obtain the UDID

Army-mac-mini-2 :~ Army $adb disconnect 192.168.3.211:5555 army-mac-mini-2 :~ Army $adb shell bm get-udid 2EW13B922B671A48C802168D245C6B5B60312OIK3D6B90678S1534B420422218Copy the code

Conclusion:

  1. Install the Scrcpy software and android-platform-tools platform software

  2. Apply for commissioning certificates and profiles (see official documentation for details)

  3. Scrcpy connects the real machine to the computer

  4. DevEco Studio debug select the real machine connected above.

  5. After the computer restarts, cast the screen onto the computer again using the following command:

    Army-mac-mini-2 :~ Army $adb Connect 192.168.3.168:6666

    Army-Mac-mini-2:~ army$ scrcpy -s 192.168.3.168:6666

One last screenshot:

The original link: developer.huawei.com/consumer/cn…

Original author: Wild Wolf _16 uncle