How to run uiautomatorviewer in java 11?

1.3k Views Asked by At

C:\Users\Shruti>uiautomatorviewer -Djava.ext.dirs=C:\Program Files\Java\jdk-11.0.14\lib;..\lib is not supported. Use -classpath instead. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

First I had java 15 but I heard java 8 is compatible for uiautomatorviewer but it didn't helped then I uprgaded it to java 11 but same issue plz help

1

There are 1 best solutions below

0
ignacio On

I couldn't make it work with Java 11 and I doubt it's possible to as there may be substantial differences in the APIs used, but I was able to run it using Java 8 while maintaining Java 11 as the default java. Simply open <android-sdk>/tools/bin/uiautomatorviewer with a text editor and replace

javaCmd="java"

with

javaCmd="/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java"

(or whatever your path to java 8 bin is located)