Search code examples
androidtestingautomated-testsappiumpython-appium

How can I correctly set up UiAutomatorViewer to inspect elements for testing Android apps with Appium?


When running uiautomatorviewer, I am getting the following NullPointerException error:

Enter image description here

I have installed and set up Appium following the setup process and set up environment variables for ANDROID_HOME and the Android SDK. The uiautomatorviewer command is using a Path user variable that points to the directory Sdk/tools/bin, where the uiautomatorviewer.bat file is located. From everything I've read online, running this executable should open up the UiAutomatorViewer application, so I can inspect elements on my Android app. Why isn't this working?


Solution

  • The correct fix for this issue:

    Java SDKs 9 and 10 do not work with Appium and the Android SDK. You have to uninstall the Java SDK for the more recent version and install the Java 8 SDK instead.

    For Linux

    Follow this process:

    1. brew cask uninstall java # uninstall java9
    2. brew tap caskroom/versions
    3. brew cask install java8 # install java8
    4. touch ~/.android/repositories.cfg # without this file, error will occur on next step
    5. brew cask install android-sdk

    For Windows

    1. Open Add or Remove Programs menu and uninstall Java 9/10.
    2. Install Java 8 using the installer.