...
Install Android Studio if you don’t have it
Open Android Studio
Click on More Actions > SDK Manager (or Tools > SDK Manager if a project is open)
Click on the SDK tools tab, uncheck option "Hide Obsolete Packages"
Check option “Android SDK Tools” and install version 26.1.1
UIAutomatorViewer is now installed in Android SDK directory
Add UIAutomatorViewer to your path:
On Linux: add the line
export PATH=$HOME/Android/Sdk/tools/bin:$PATH
in the .bashrc file and run the command "source ~/.bashrc"On Mac: add the line
export PATH=$HOME/Library/Android/sdk/tools/bin:$PATH
in the .bash_profile file and run the command "source ~/.bash_profile"On Windows: Windows start menu > Settings > System > About > Advanced settings > Environment variables > Path > Modify > Add the path
C:\Users\[username]\AppData\Local\Android\Sdk\tools\bin
. Replace username by the name of the user.
Noteinfo |
---|
UIAutomatorViewer needs a JDK Java 1.8 by default to work |
2. Launch UIAutomatorViewer
Check your java version with the following command:
Code Block | ||
---|---|---|
| ||
java -version |
2.1. Launch UIAutomatorViewer without installing
...
Java 1.8
...
Note |
---|
If you use a Mac, please follow the next part. |
To avoid installing a different version of javaJava, you could set environment variables for your PC profile:
Linux |
---|
Mac
Windows | |
---|---|
ANDROID_HOME | Edit the ~/.bashrc file:
|
Edit the ~/.bash_profile file:
export ANDROID_HOME=$HOME/Library/Android/sdk
Windows start menu > Settings > System > About > Advanced settings > Environment variables > Path > Add:
Replace username by the name of the user. | |
JAVA_HOME | Edit the ~/.bashrc file:
If jbr is not present (old version of Android Studio) replace it by jre |
Edit the ~/.bash_profile file:
export JAVA_HOME="/Applications/Android Studio. |
Windows start menu > Settings > System > About > Advanced settings > Environment variables > Path > Add:
If jbr is not present (old version of Android Studio) replace it by jre. | |
PATH | Edit the ~/.bashrc file:
|
Edit the ~/.bash_profile file:
export PATH=$JAVA_HOME/bin:$PATH
Windows start menu > Settings > System > About > Advanced settings > Environment variables > Path > Modify > Add the path:
|
After adding the variables, you can open a new terminal (this is important to open a new terminal to take into account the variable variables you have just set) and use the following command to open uiautomatorviewer UIAutomatorViewer :
For Windows On Linux :
Code Block | ||
---|---|---|
| ||
java -Xmx1600M -Dcom.android.uiautomator.bindir="%ANDROID$ANDROID_HOME%\HOME/tools" -cp "%ANDROID$ANDROID_HOME%\HOME/tools\/lib\/x86_64\/swt.jar";:"%ANDROID$ANDROID_HOME%\HOME/tools\/lib\/*" com.android.uiautomator.UiAutomatorViewer |
For Linux On Windows :
Code Block | ||
---|---|---|
| ||
java -Xmx1600M -Dcom.android.uiautomator.bindir="$ANDROID%ANDROID_HOME/HOME%\tools" -cp "$ANDROID%ANDROID_HOME/HOME%\tools/\lib/\x86_64/\swt.jar":;"$ANDROID%ANDROID_HOME/HOME%\tools/\lib/\*" com.android.uiautomator.UiAutomatorViewer |
The following program appears :
...
2.2. Launch UIAutomatorViewer with
...
Java 1.8
...
Install Java 1.8:
On Linux, do this on a new terminal run the following commands:
Code Block | ||
---|---|---|
| ||
# Install java 8 sudo apt-get install openjdk-8-jdk # Check java version java -version # Update the java default version use by your system (if you have several) sudo update-alternatives --config java |
On Mac, run the following command:
Code Block | ||
---|---|---|
| ||
brew install openjdk@8 |
On Mac, add the line
export PATH=/usr/local/opt/openjdk@8/bin:$PATH
in the .bash_profile file and run the command "source ~/.bash_profile"On Windows, install Java 1.8 by getting it on Oracle site web, the Oracle website. You need to create an account.
Launch UIAutomatorViewer:
On Linux , on a new terminal, go to the directory
$HOME/Android/Sdk/tools/bin
and tap the and Mac, run the following command:
Code Block | ||
---|---|---|
| ||
uiautomatorviewer |
On Windows, on a new terminal, go to the directory
C:\Users\[username]\AppData\Local\Android\Sdk\tools\bin
and tap run the following command:
Code Block | ||
---|---|---|
| ||
uiautomatorviewer.bat |
The following program appears :
...
Info |
---|
On macOSMac, interactions may be impossible with uiautomatorviewerUIAutomatorViewer. If it is the case, do the following steps:
|
3. Use UIAutomatorviewer
...