6

I am unable to launch uiautomator through mac terminal. I get the below error when I typed Android or Uiautomator in the 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
2
  • 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, 2017 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, 2017 at 12:03

6 Answers 6

1

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.

1

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

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

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.

0

This problem is fixed when I switch to a lower version(1.8) of Java. It seems UIAutomator doesn't support the latest one.

The lines in my .zshrc

# Java Home
# export JAVA_HOME='/opt/homebrew/Cellar/openjdk/19.0.1/libexec/openjdk.jdk/Contents/Home'
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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