UIautomatorviewer need Java 1.8.0_231 only !!
When you run UIautomatorviewer on mac It need specific JAVA version 1.8.0_231
Step to revert to a prior version of JAVA
To uninstall Java from a Mac, you will remove one directory and one file, as follows:1. Click on the Finder icon located in your dock2. Click on the Utilities folder3. Double-click on the Terminal icon4. In the Terminal window Copy and Paste the following command:sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin5. Press enter. You may be prompted to enter your computer password before continuing.6. Next, Copy and Paste the command below and press enter:sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefpaneNote: Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.
Then download JAVA 1.8.0_231 from below
After that install It.