简体   繁体   English

运行 UI AUTOMATOR 时出错,使用 java 1.8

[英]Getting Error while running UI AUTOMATOR , using java 1.8

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当我在终端中打开 uiatuomator 时,它工作正常,但是一旦我点击 uiautomator 连接到模拟器,我就会得到这个异常

Android API- 29 Android API- 29

在此处输入图像描述

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

this problem is happening for java SDK version. java SDK 版本出现此问题。 I had java version 1.8.262 and I got multiple problems even setting up the path variables properly.我有 java 版本 1.8.262,即使正确设置路径变量,我也遇到了多个问题。 you can try...你可以试试...

after changing the java version and setting up the path variable properly.更改 java 版本并正确设置路径变量后。 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 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.在你的 bash_profile 中设置环境。 to do that - go to MAC DISK and find ".bash_profile" Open,edit and put the path要做到这一点 - go 到 MAC DISK 并找到“.bash_profile” 打开,编辑并放置路径

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退出终端并重新打开类型“uiautomatorviewer”并按Enter

that it.那它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用UI自动化器从运行的应用程序中删除应用程序 - Remove app from running apps by swiping out using UI automator 使用UI Automator进行Android测试 - Android Testing using UI Automator UI Automator:获取UI层次结构XML文件时出错:com.android.ddmlib.TimeoutException - UI Automator:Error while obtaining UI hierarchy XML file: com.android.ddmlib.TimeoutException 使用Eclipse使用Ant构建运行robolectric时遇到java.lang.ClassCastException错误 - Getting java.lang.ClassCastException error while running robolectric using ant build using eclipse Ui automator 查看器--&gt; 设备截图,原因:创建临时文件以保存快照时出错:空 - Ui automator viewer--> Device screenshot, Reason : Error while creating temporary file to save snapshot : null 如何使用 Android UI Automator 双击 - How to DoubleTap using Android UI Automator 如何使用Java,Selenium为Android自动化(例如UI Automator)上的每个元素添加边框颜色 - How to put border colour to every element on android automation like UI Automator using java, selenium 使用Java SDK 1.8中的BasicFileAttributes获取上次文件访问时间 - Getting last file access time using BasicFileAttributes in Java SDK 1.8 如何在UI Automator中长按时检查UI对象 - How check for UI object while long-pressed in UI Automator 使用Android Studio运行App Engine后端时出错 - Getting error while running app engine backend using android studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM