Run UI Automator Viewer on ARM/aarch64 macOS
At the time of writing this blog. Some tools (Like
uiautomatorviewer
) in the Android SDK are not compatible with ARM macOS.However, the
uiautomatorviewer
is a Java program. It can be easily “hacked” to run on ARM machines.
Preparations
- JRE 8. I chose
Zulu-8
(Java 9+ may has more difficulties to work well. I gave up to make it run onopenjdk-19
) - Eclipse SWT 4.20 for macosx-aarch64
Install SWT
Goto the Android SDK tools directory.
1
cd ANDROID_HOME/tools
Create
lib/aarch64
directory.1
mkdir lib/aarch64
Copy
lib/x86_64/swt.jar
tolib/aarch64/swt.jar
1
cp lib/x84_64/swt.jar lib/aarch64/swt.jar
Copy SWT 4.20 jar to
lib/aarch64/
asswt2.jar
1
cp /downloaded/swt/jar/path lib/aarch64/swt2.jar
Run the uiautomatorviewer
Make sure you are currently running Java 8
1 | java -version |
In ANDROID_HOME/tools
, run the command:
1 | bin/uiautomatorviewer |
Java 9+ ?
Since Java 9, -Djava.ext.dirs
parameter was unsupported.
You should try to use -classpath
instead.
-classpath
is useless when using -jar
.
To add external classes when running a jar, should use -Xbootclasspath/a:
instead.
Example
1 | java -Xbootclasspath/a:"lib/aarch64/swt2.jar:lib/aarch64/swt.jar:lib/others.jar" -XstartOnFirstThread -jar lib/uiautomatorviewer-26.0.0-dev.jar |
I’ve tried this, but ran into some other issues.
Reference
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment