3

When i open uiatuomator in terminal it works fine but as soon as i click on uiautomator to connect to the emulator i get this exception

Android API- 29

enter image description here

Exception on Terminal :

Unhandled event loop exception during blocked modal context.
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.SWT.error(Unknown Source)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Unknown Source)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:173)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:388)
    at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
    at com.android.uiautomator.actions.ScreenshotAction.run(ScreenshotAction.java:85)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:452)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.notifyListeners(Unknown Source)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(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)
Caused by: 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.jface.dialogs.Dialog.shortenText(Dialog.java:349)
    at org.eclipse.jface.dialogs.ProgressMonitorDialog.setMessage(ProgressMonitorDialog.java:652)
    at org.eclipse.jface.dialogs.ProgressMonitorDialog.access$3(ProgressMonitorDialog.java:644)
    at org.eclipse.jface.dialogs.ProgressMonitorDialog$3.run(ProgressMonitorDialog.java:406)
    at org.eclipse.swt.widgets.RunnableLock.run(Unknown Source)
    ... 22 more
Shah
  • 553
  • 5
  • 12

1 Answers1

7

this problem is happening for java SDK version. I had java version 1.8.262 and I got multiple problems even setting up the path variables properly. you can try...

after changing the java version and setting up the path variable properly. I got that it's working.

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