Skip to content

Instantly share code, notes, and snippets.

@paragbaxi
Created February 20, 2026 15:35
Show Gist options
  • Select an option

  • Save paragbaxi/3c1b53544f6ce347108a2a7de43f598a to your computer and use it in GitHub Desktop.

Select an option

Save paragbaxi/3c1b53544f6ce347108a2a7de43f598a to your computer and use it in GitHub Desktop.
Launch uiautomatorviewer-gradle on macOS (Apple Silicon / JDK 17) without crashing
#!/usr/bin/env bash
# Launch uiautomatorviewer-gradle on macOS with JDK 17
# Without JAVA_HOME + -XstartOnFirstThread, the app crashes immediately on macOS.
#
# Source: https://github.com/pvmagacho/uiautomatorviewer-gradle
# Fix: https://github.com/paragbaxi/uiautomatorviewer-gradle
# 1. Build
./gradlew -Dorg.gradle.java.home="/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home" installDist
# 2. Launch
JAVA_HOME="/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home" \
JAVA_OPTS=-XstartOnFirstThread \
./build/install/uiautomatorviewer-gradle/bin/uiautomatorviewer-gradle
# Note: -XstartOnFirstThread is macOS-only and cannot be added to the shell wrapper script,
# so it must be passed via JAVA_OPTS at launch time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment