gpt4 book ai didi

android - 使用 java 1.8 运行 UI AUTOMATOR 时出错

转载 作者:行者123 更新时间:2023-12-04 00:55:32 25 4
gpt4 key购买 nike

当我在终端中打开 uiatuomator 时它工作正常但是当我点击 uiautomator 连接到模拟器时我得到这个异常

Android API- 29

enter image description here

终端异常:

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

最佳答案

java SDK 版本出现此问题。我有 java 版本 1.8.262,即使正确设置路径变量,我也遇到了多个问题。你可以试试……

更改 java 版本并正确设置路径变量后。我知道它正在工作。

将您的 Java 版本降级到“1.8.0_231”,您可以在此处获取:https://www.oracle.com/java/technologies/javase/javase8u211-later-archive-downloads.html

在你的 bash_profile 中设置环境。要做到这一点 - 转到 MAC DISK 并找到“.bash_profile”打开,编辑并放置路径

示例:

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

退出终端并重新打开输入“uiautomatorviewer”并回车

它。

关于android - 使用 java 1.8 运行 UI AUTOMATOR 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62786276/

25 4 0
文章推荐: functional-programming - 从 sml 中的整数对列表返回偶数列表
文章推荐: scala - 为什么以及何时需要在方法名称后面加上 _?
文章推荐: javascript -