unable to start uiautomatorviewer in windows due to classpath error

812 Views Asked by At

I am unable to start uiautomatorviewer due to below error:

C:\Users\176226\AppData\Local\Android\Sdk\tools\bin>uiautomatorviewer
-Djava.ext.dirs=..\lib\x86_64;..\lib is not supported.  Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

I have added all the needed paths for tools, cmd-tools and platform tools and android_home in env variables

below are details of java version used. Can uiautomator be used without having to downgrade java version:

openjdk version "17.0.2" 2022-01-18 LTS
OpenJDK Runtime Environment Zulu17.32+13-CA (build 17.0.2+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.32+13-CA (build 17.0.2+8-LTS, mixed mode, sharing)

Appreciate help

1

There are 1 best solutions below

0
Eric On

this was a real adventure....

  1. download and install specifically JDK version 8 (not JRE or any other version) https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html

  2. add JDK8 to your environemnt path as JAVA_HOME..for example: enter image description here

  3. make sure %ANDROID_HOME%\tools\bin is also added to your Path as well so that you can run uiautomatorviewer from any directory enter image description here

  4. in terminal, run uiautomatorviewer