1

机器
MacBook Air M1

操作系统
macOS Big Sur 版本 11.5.2

java版本

java版本“1.8.0_301”

Java(TM) SE 运行时环境 (build 1.8.0_301-b09)

Java HotSpot(TM) 64 位服务器 VM(内部版本 25.301-b09,混合模式)

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

在终端上运行 uiautomatorviewer 我得到以下异常

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)

请让我知道是否有人能够遇到类似的问题并有解决方案。

谢谢,纳希德

4

1 回答 1

1

我找到了比 uiautomator 更好的替代方案 - appium 检查器。

如果你已经在你的 mac 上安装了 appium GUI,请按照以下步骤操作:

  1. 启动appium服务器
  2. 单击搜索按钮以启动 appium 检查器 在此处输入图像描述
  3. 在下面提供您的 android 配置 {
    "platformName": "Android",
    "platformVersion": "8.1", //<>
    "app": "/path/to/.apk/file", "deviceName": "c33143r", //<<get device name using: $ adb devices>>
    "automationName": "UiAutomator2"
    }
于 2021-09-05T13:05:10.247 回答