2

I am trying to run UiAUtomatorViewer from command prompt on Windows10 machine. But it keeps giving the following error when I run uiautomatorviewer.bat from the Sdk\tools\bin directory.

-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.

(image of above error for reference)

JAVA_HOME, ANDROID_HOME environment variables are set and I am able to use adb commands like adb devices etc well. I also added Java install directory to the PATH variable. Any suggestions?

Ryan M
  • 18,333
  • 31
  • 67
  • 74
shmit
  • 2,306
  • 2
  • 16
  • 20
  • Does this answer your question? [uiautomatorviewer - Error: Could not create the Java Virtual Machine](https://stackoverflow.com/questions/49506036/uiautomatorviewer-error-could-not-create-the-java-virtual-machine) – Gabor Aug 12 '21 at 17:11

2 Answers2

1

Downgrade your Java version to "1.8.0_231" you can get here: https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html

set the env in your bash_profile. to do that - go to MAC DISK and find ".bash_profile" Open,edit and put the path

example:

export ANDROID_HOME=~/Library/Android/sdk
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home

export PATH=$PATH:$JAVA_HOME/bin
export PATH=$PATH:$JAVA_HOME/lib
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/build-tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/tools/lib/x86_64

quit the terminal and reopen type "uiautomatorviewer" and hit enter

that it.

shofin
  • 144
  • 5
  • I can try that but how is appium able to use the current version of Java to run the tests? – shmit Aug 13 '20 at 12:52
0

In command prompt type following on Window machine

go to the bin directory

**cd C:\Users\<username>\AppData\Local\Android\Sdk\tools\bin>**

Set JAVA_HOME on command prompt by typing

**set JAVA_HOME = C:\Program Files\Android\Android Studio\jre**       

then run UIAutomator,

uiautomatorviewer.bat

Note : The set command does not save values between cmd.exe sessions. So JAVA_HOME is set to above temporary. So every time you need to do above steps for new cmd.exe sessions.