Sunday, July 30, 2023

UiAutomatorViewer isn't working with higher java versions.

 

I was getting this error when tried with my default Java 11;

./uiautomatorviewer -Djava.ext.dirs=/Users/yumani/Library/Android/sdk/tools/lib/x86_64:/Users/yumani/Library/Android/sdk/tools/lib is not supported. Use -classpath instead. Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit

The problem seems to be caused by the usage of the -Djava.ext.dirs option, which is not supported in newer versions of Java. 

Then, I used use -classpath option to set the classpath and got this error

yumani@Yumanis-MacBook-Pro bin % ./uiautomatorviewer -classpath /Users/yumani/Library/Android/sdk/tools/lib/x86_64:/Users/yumani/Library/Android/sdk/tools/lib -Djava.ext.dirs=/Users/yumani/Library/Android/sdk/tools/lib/x86_64:/Users/yumani/Library/Android/sdk/tools/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 am on Java11,  tried different options in the net such as upgratig sdk-tools, downloading swt.jar.

Non worked for me in macOS Ventura.

The web advise that worked was downgrading to jdk 1.8.

So I installed jdk 1.8, updated in .bash_profile, commented out my older version (because I want to switch back to it when I am not using the UiAutomatorViewer.

source ~/.bash_profile 

yumani@Yumanis-MacBook-Pro sdk % tools/bin/uiautomatorviewer -classpath /Users/yumani/Library/Android/sdk/tools/lib/x86_64/swt.jar






No comments:

Post a Comment

Featured

Selenium - Page Object Model and Action Methods

  How we change this code to PageObjectModel and action classes. 1 2 3 driver . findElement ( By . id ( "userEmail" )). sendKeys (...

Popular Posts