When the MAC M1 uiautomatorviewer is opened, it displays blank or reports an error

As shown in the following figure: uiautomatorviewer displays blank

Cause: the problem of java version is too new

➜  sdk  ls /Library/Java/JavaVirtualMachines/
jdk1.8.0_161.jdk zulu-17.jdk

Solution: downgrade

The Java version can be downgraded to before 201 or before 51. (the blogger’s 161 failed, which may also be the reason for the M1 chip)
uiautomatorviewer is actually a Java startup script. For example, you can use this command on the Mac to see the real startup command.

bash -x /Users/zhoujing/Library/Android/sdk/tools/bin/uiautomatorviewer

In order to ensure that the uiautomatorviewer can run correctly locally, several jdks can be standby

Link to download old java version: SDK

References:
1. Error reporting after uiautomatorviewer is opened under MAC
2. Learning experience of MAC Android automatic test

Read More: