Overview
We need to install these packages to run Appium server, and I will show you how to make it step by step.
- node.js
- android-sdk
- adb
- appium & drivers
- appium-doctor
Works on Ubuntu 22.04 (Raspberry Pi, ARM64) and Ubuntu 24.04 (WSL)
Installation
STEP 1. INSTALL Node.js
- Update the OS to the latest
$ sudo apt update && sudo apt upgrade -y
- Use "apt show ..." command to preview the nodejs version, if it less than 18.0.0 means it can't supports Appoim 2.x, you need download and install it manually.
$ apt show nodejs
Package: nodejs
Version: 18.19.1+dfsg-6ubuntu5
...
- Download and install node.js manually.
- Refer to "The nodesource for node.js"
- Install "curl" tool first
$ sudo apt install curl -y
- Find the target version (LTS version is recommended)
- Download the setup script
- You will see a "nodesource_setup.sh" file exists in the current directory
$ curl -fsSL https://deb.nodesource.com/setup_23.x -o nodesource_setup.sh
- Run the setup script with sudo
$ sudo -E bash nodesource_setup.sh
- Install Node.js
$ sudo apt install nodejs
- Verify nodejs and npm installation
$ node -v
v23.11.1
$ npm -v
10.9.2
STEP 2. INSTALL android-sdk and adb
- Install android-sdk
$ sudo apt install android-sdk -y
- Install adb
$ sudo apt install adb -y
STEP 3. SET ANDROID_HOME and PATH
- Find the locate of android-sdk
$ whereis android-sdk
android-sdk: /usr/lib/android-sdk
- Append \$ANDROID_HOME and \$PATH environment variables in ~/.bashrc
$ echo 'export ANDROID_HOME=/usr/lib/android-sdk' >> ~/.bashrc
$ echo 'export PATH=$PATH:$ANDROID_HOME/tools' >> ~/.bashrc
$ echo 'export PATH=$PATH:$ANDROID_HOME/platform-tools' >> ~/.bashrc
- Activate
$ source ~/.bashrc
STEP 4. INSTALL appium and drivers
- Install appium
$ sudo npm install -g appium
- Install drivers
- For Android device
$ appium driver install uiautomator2
- For iOS device
$ appium driver install xcuitest
STEP 5. DIAGNOSTIC
- When the all installation steps finished, let's install appium-doctor for diagnostic
- Install appium-doctor
$ sudo npm install -g appium-doctor
- Execute "appium-doctor" command and make sure the necessary dependencies of diagnostic should be passed excepted "✖ android, emulator, apkanalyzer could NOT be found in /usr/lib/android-sdk/!".
$ appium-doctor
WARN AppiumDoctor [Deprecated] Please use appium-doctor installed with "npm install @appium/doctor --location=global"
info AppiumDoctor Appium Doctor v.1.16.2
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor ✔ The Node.js binary was found at: /usr/bin/node
info AppiumDoctor ✔ Node version is 20.14.0
info AppiumDoctor ✔ ANDROID_HOME is set to: /usr/lib/android-sdk/
info AppiumDoctor ✔ JAVA_HOME is set to: /usr/lib/jvm/java-11-openjdk-arm64
info AppiumDoctor Checking adb, android, emulator, apkanalyzer
info AppiumDoctor 'adb' is in /usr/lib/android-sdk/platform-tools/adb
WARN AppiumDoctor ✖ android, emulator, apkanalyzer could NOT be found in /usr/lib/android-sdk/!
info AppiumDoctor ✔ 'bin' subfolder exists under '/usr/lib/jvm/java-11-openjdk-arm64'
info AppiumDoctor ### Diagnostic for necessary dependencies completed, one fix needed. ###
info AppiumDoctor
...
STEP 6. VERIFY appium server can be executable
- Verify appium server can be executable and it expected printed logs likes below.
- Make sure the appium server version starts with v2.x
$ appium -v
2.18.0
$ appium
[Appium] Welcome to Appium v2.18.0
[Appium] The autodetected Appium home path: /home/victor/.appium
[Appium] Attempting to load driver uiautomator2...
...
STEP 7. RUN Appium Server
- Now, we can run Appium server, the command format likes below
$ appium [-a ADDRESS] [-p port] [desired capabilities] [--log=$output_path]
- Here are some frequently used examples of mine
# For Linux
# Run Appium Server With MKDIR*
$ mkdir -p $HOME/adb_log && appium -a 127.0.0.1 -p 4723 --allow-cors --session-override --relaxed-security --log-timestamp --local-timezone -g=$HOME/adb_log/AppiumServer_$(date +"%Y%m%d-%H%M%S").log
# For Windows
# Run Appium Server With MKDIR*
$ mkdir -p C:\\adb_log || appium -a 127.0.0.1 -p 4723 --allow-cors --session-override --relaxed-security --log-timestamp --local-timezone -g=C:/adb_log/AppiumServer_%date:~0,4%%date:~5,2%%date:~8,2%_%Time:~0,2%%Time:~3,2%%Time:~6,2%.log
# The output log will be created automatically by current time, to acheive it, you need create a adb_log folder under C disk and set time format.
# The %date% & %time% format on computer should be "2024-06-03" "17:04:06.54".
Reference
- Installing node.js and npm
- The nodesource for node.js
- Installing Appium-doctor
- How to set $ANDROID_HOME variable
- It's NOT a practical step, you can refer to it but not copy it.
- https://stackoverflow.com/questions/26256279/how-to-set-android-home-path-in-ubuntu
- Change datetime format in Windows 11
- Migrating from Appium 1 to 2