0

I recently updated my Mac OS to Big Sur. After that uiautomatorviewer is not working.

Before Big Sur, uiautomatorviewer use to work.

I am getting the below error:

/Users/xxxx/Library/Android/sdk/tools/bin/uiautomatorviewer ; exit;

java.lang.NullPointerException

at org.eclipse.swt.widgets.Control.internal_new_GC(Unknown Source)

at org.eclipse.swt.graphics.GC.(Unknown Source)

at org.eclipse.swt.graphics.GC.(Unknown Source)

at org.eclipse.swt.widgets.Tree.computeSize(Unknown Source)

at org.eclipse.swt.layout.GridData.computeSize(Unknown Source)

at org.eclipse.swt.layout.GridLayout.layout(Unknown Source)

at org.eclipse.swt.layout.GridLayout.computeSize(Unknown Source)

at org.eclipse.swt.widgets.Composite.computeSize(Unknown Source)

at org.eclipse.swt.custom.SashFormLayout.computeSize(Unknown Source)

at org.eclipse.swt.widgets.Composite.computeSize(Unknown Source)

at org.eclipse.swt.custom.SashFormLayout.computeSize(Unknown Source)

at org.eclipse.swt.widgets.Composite.computeSize(Unknown Source)

at org.eclipse.swt.layout.FillData.computeSize(Unknown Source)

at org.eclipse.swt.layout.FillLayout.computeChildSize(Unknown Source)

at org.eclipse.swt.layout.FillLayout.computeSize(Unknown Source)

at org.eclipse.swt.widgets.Composite.computeSize(Unknown Source)

at org.eclipse.swt.layout.GridData.computeSize(Unknown Source)

at org.eclipse.swt.layout.GridLayout.layout(Unknown Source)

at org.eclipse.swt.layout.GridLayout.layout(Unknown Source)

at org.eclipse.swt.widgets.Composite.updateLayout(Unknown Source)

at org.eclipse.swt.widgets.Composite.updateLayout(Unknown Source)

at org.eclipse.swt.widgets.Composite.layout(Unknown Source)

at org.eclipse.swt.widgets.Display.runSettings(Unknown Source)

at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)

at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)

at org.eclipse.jface.window.Window.open(Window.java:801)

at com.android.uiautomator.UiAutomatorViewer.main(UiAutomatorViewer.java:78)


/usr/libexec/java_home -V

Matching Java Virtual Machines (2):

1.8.291.10 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

1.8.0_291 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home


Java version: java version "1.8.0_291"

Java(TM) SE Runtime Environment (build 1.8.0_291-b10)

Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)


which java

/usr/bin/java


echo $JAVA_HOME

/Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home


echo $ANDROID_HOME

/Users/totjyoth/Library/Android/sdk


Bash profile:

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

export ANDROID_HOME=~/Library/Android/sdk

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


appium -v

1.20.2


Android Studio

Version 4.2


I am using Eclipse IDE

Eclipse IDE for Enterprise Java Developers.

Version: 2019-12 (4.14.0)

Build id: 20191212-1212


I tried 'monitor', but that also gave an error:

xxxxx$ monitor JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/lib/libserver.dylib JavaVM FATAL: Failed to load the jvm library. enter image description here

1

1 Answer 1

2

I've found a solution here: https://github.com/android/android-test/issues/911#issuecomment-849389068.

Basically, you download the newest swt.jar from Eclipse site and use it (under a different name, e.g. swt2.jar) when starting uiautomatorviewer, something like:

java -Xmx1600M -XstartOnFirstThread -Dcom.android.uiautomator.bindir="$ANDROID_HOME/tools" -Djava.ext.dirs=$ANDROID_HOME/tools/lib/x86_64:$ANDROID_HOME/tools/lib -cp "$ANDROID_HOME/tools/lib/x86_64/swt.jar":"$ANDROID_HOME/tools/lib/*" -jar $ANDROID_HOME/tools/lib/uiautomatorviewer-26.0.0-dev.jar
4
  • 1
    Thanks for the link! I copied swt.jar into ~/Library/Android/sdk/tools/lib/x86_64/swt2.jar and it worked right away for me. (No need for modifying the uiautomatorviewer launch command.)
    – Matt
    Jun 13, 2021 at 20:39
  • 1
    Also, in case it helps anyone, I downloaded the 4.19 Mac OSX (64 bit version) release of the SWT Binary and Source for my (non-ARM) MacBook Pro. You can find other releases on the Eclipse Project Downloads page.
    – Matt
    Jun 13, 2021 at 20:41
  • 3
    I did all of the above but I am seeing the below error -Djava.ext.dirs=/Users/XXXXX/Library/Android/sdk/tools/lib/x86_64:/Users/XXXX/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. Sep 17, 2021 at 8:16
  • This seems to work only with Java 1.8, Java 11 or later results in this "Use -classpath instead." message
    – SqAR.org
    Feb 22, 2023 at 22:44

Your Answer

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

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