4

I am unable to launch uiautomator through mac terminal. I get the below error when I typed Android or Uiautomator in terminal, or click uiautomator from tool folder.

ERROR Djava.ext.dirs=/Users/ade/Library/Android/sdk/tools/lib/x86‌​_64:/Users/ade/Libra‌​ry/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. logout Saving session... ...copying shared history... ...saving history...truncating history files... ...completed. [Process completed]

My PATH is

export JAVA_HOME=$(/Users/ade/Documents/java_home) 
PATH=$PATH:$JAVA_HOME 
export M2_HOME=/Users/ade/Documents/apache-maven-3.5.2 
export PATH=$PATH:$M2_HOME/bin 
ANDROID_HOME=/users/ade/Library/Android/sdk 
export PATH=$PATH:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-to‌​ols
  • Have you tried using the command in the form Uiautomator -classpath:/Users/ade/Library/Android/sdk/tools/lib? Alternatively, you could try some of the options in the related questions list. – Kate Paulk Dec 29 '17 at 18:49
  • I have tried everything and still couldn't get it to work. Here is the path I have set below. export JAVA_HOME=$(/Users/ade/Documents/java_home) PATH=$PATH:$JAVA_HOME export M2_HOME=/Users/ade/Documents/apache-maven-3.5.2 export PATH=$PATH:$M2_HOME/bin ANDROID_HOME=/users/ade/Library/Android/sdk export PATH=$PATH:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools – Tessy Dec 30 '17 at 12:03
0

You should not use uiautomator in first place.

The recommended tool by Google from Android SDK is uiautomatorviewer

Which you can find in the same folder: "Libra‌​ry/Android/sdk/tools‌​/lib"

If you can't find uiautomatorviewer, please update your Android SDK.

0

Getting rid of the current java version (I had Java 9 installed) and using homebrew to install Java 8 solved the issue.

Find the installed java version using

java -version

Then using homebrew

brew tap caskroom/versions
brew cask install java8

That should do the trick, hope it helps!

0

After seen your path configurations, What I observed few needs to be updated as below:

  1. export JAVA_HOME=$(/Users/ade/Documents/java_home) should be like :[Verify in your local machine/ Sharing just to refer] /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre

  2. export M2_HOME=/Users/ade/Documents/apache-maven-3.5.2 should be like : M2_HOME=/usr/local/Cellar/maven/3.5.0/libexec

Hope this will help. #AllTheBest

0
export 

    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home

    export ANDROID_HOME=/Users/username/android-sdks
    export PATH=$PATH:$ANDROID_HOME/platform-tools
    export PATH=$PATH:$ANDROID_HOME/build-tools
    export PATH=$PATH:$ANDROID_HOME/tools
    export M2_HOME=/usr/local/Cellar/maven/3.5.4
    export PATH=$PATH:$M2_HOME/bin

Re-start mac

Type

echo $JAVA_HOME
echo $ANDROID_HOME
echo $M2_HOME

And check for results

Also try adb devices It should result your connected device Then go to tools from Terminal

cd /Users/username/android-sdks/tools 

Then type Uiautomatorviewer

This should open the Uiautomatorviewer.

0

Am running into the same problem. Have setup as advised in this thread, but no luck. After setting bash_profile with the above for JAVA_HOME, ANDROID_HOME and M2_HOME, restarted machine and uiautomatorviewer still shows the same error

  • Error from terminal -

Djava.ext.dirs=/Users/appiummac/Android/sdk/tools/lib/x86_64:/Users/appiummac/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.

If any could resolve this already, please help me through this. Screenshot of home paths is attached.

Screenshot of home paths

0

I was having JDK10.0.1 version on my machine and it seems not compatible with UIautomatorviewer. So, Uninstalled JDK10.0.1 and installed JDK8 and able to launch UIautomatorviewer with no issues. Thanks to all who looked into my question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.