appiumuiautomatorviewer

I cannot run uiautomatorviewer on my macbook M1


Machine
macBook Air M1

OS
macOS Big Sur Version 11.5.2

java -version

java version "1.8.0_301"

Java(TM) SE Runtime Environment (build 1.8.0_301-b09)

Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)

bash_profile

   export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home
   export PATH=$PATH:$JAVA_HOME/bin
   export PATH=$PATH:$JAVA_HOME/lib
   export MAVEN_HOME=/Users/XXX/Documents/apache-maven-3.8.2
   export M2=$MAVEN_HOME/bin
   export ANDROID_HOME=/Users/XXX/Library/Android/sdk
   export PATH=$PATH:/usr/local/git/bin:/usr/local/bin:
   export PATH=$PATH:$ANDROID_HOME/platform-tools
   export PATH=$PATH:$ANDROID_HOME/tools
   export PATH=$PATH:$ANDROID_HOME/tools/bin
   export PATH=$PATH:$ANDROID_HOME/emulator
   export PATH=$PATH:$ANDROID_HOME/build-tools
   export PATH=$PATH:$ANDROID_HOME/tools/lib/x86_64

On running uiautomatorviewer on terminal i get below exception

java.lang.NullPointerException
at org.eclipse.swt.widgets.Control.internal_new_GC(Unknown Source)
at org.eclipse.swt.graphics.GC.<init>(Unknown Source)
at org.eclipse.swt.graphics.GC.<init>(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)

Please let me know if anyone was able experience a similar issue and has a solution.

Thanks, Nahid


Solution

  • I have found a better alternative than uiautomator - appium inspector.

    If you have installed appium GUI on your mac follow below steps:

    1. Start appium server
    2. Click the search button to start the appium inspector enter image description here
    3. Provide below your android configurations {
      "platformName": "Android",
      "platformVersion": "8.1", //<>
      "app": "/path/to/.apk/file", "deviceName": "c33143r", //<<get device name using: $ adb devices>>
      "automationName": "UiAutomator2"
      }