[英]uiautomatorviewer not working on latest MacOS
I am trying to using uiautomatorviewer on MacOS 10.15.我正在尝试在 MacOS 10.15 上使用 uiautomatorviewer。 I got the below error.
我收到以下错误。
I tested uiautomatorviewer
on MacOS 10.13.我在 MacOS 10.13 上测试
uiautomatorviewer
。 it works pretty well.它工作得很好。
Here's the error message:这是错误消息:
Unexpected error while obtaining UI hierarchy java.lang.reflect.InvocationTargetException on latest Mac OS
Here's the log detail这是日志详细信息
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 ialogs.ProgressMonitorDialog$ProgressMonitor.subTask(ProgressMonitorDialog.java:234)
this problem happening for SDK version. SDK 版本发生此问题。 I solved my problem by doing the followings -
我通过执行以下操作解决了我的问题 -
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 set 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/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
quit the terminal and reopen type "uiautomatorviewer" and hit enter...退出终端并重新打开类型“uiautomatorviewer”并按回车键...
thats it.而已。
TL;DR: What worked in my case was doing a downgrade of the Java version I was using. TL;DR:在我的情况下,我正在使用的 Java 版本降级。
To quickly do this I recommend installing sdkman and install a lower version of your current Java version.为了快速做到这一点,我建议安装sdkman并安装当前 Java 版本的较低版本。
In my case I was using the 8.0.262.hs-adpt
(as listed in SDKman) and having troubles like no visible text/null pointer exceptions at terminal.在我的情况下,我使用的是
8.0.262.hs-adpt
(如 SDKman 中所列)并且遇到了终端上没有可见文本/空指针异常等问题。
After downgrade to 8.0.252.hs-adpt
, all error are gone and currently working.降级到
8.0.252.hs-adpt
后,所有错误都消失了,目前正在运行。
Detailed steps:详细步骤:
curl -s "https://get.sdkman.io" | bash
)curl -s "https://get.sdkman.io" | bash
)8.0.262
: sdk list java
(in my case the AdoptOpenJDK 8.0.252.hs-adpt
)8.0.262
的 JDK: sdk list java
(在我的例子中是AdoptOpenJDK 8.0.252.hs-adpt
)sdk install java <VERSION_YOU_CHOOSE>
sdk install java <VERSION_YOU_CHOOSE>
uiautomatorviewer
in the same terminal you installed the JDK.uiautomatorviewer
。 You can also use sdk use java <VERSION>
in case you already have another JDK installed or sdk default java <VERSION>
in case you want you want to always point to an specific version. You can also use
sdk use java <VERSION>
in case you already have another JDK installed or sdk default java <VERSION>
in case you want you want to always point to an specific version.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.