Setting up the Android Development Environment Variable for macOS
Configure the ANDROID_HOME environment variable on macOS to enable Appium-based mobile app automation testing.
Prerequisites
Ensure that Android Studio, Android Software Development Kits (SDKs), and Emulators are successfully installed and configured before proceeding with further setup steps.
Download and install Android Studio from the official website: Android Studio. Install the necessary SDK platforms. Create and configure Android Emulators for testing.
If you encounter any issues while scraping or executing a mobile automation script on macOS, then perform the following to set up the Android environment variable:
- To run the
nano ~/.bash_profilecommand on a Mac, perform the following:-
Open Terminal: You can find Terminal in the "Utilities" folder within the "Applications" folder, or you can use Spotlight search (Cmd+Space, then type "Terminal").
-
Run the command:
In the Terminal window, type
nano ~/.bash_profileand press Enter. This command opens the Bash profile file (~/.bash_profile) in the Nano text editor or your preferred text editor. If the file doesn't exist, Nano creates a new one. The~represents your home directory.
-
- In the Nano text editor, update your Android SDK path by adding the following line:
This line sets the environment variable
export ANDROID_HOME=/Users/<Username>/Library/Android/sdkANDROID_HOMEto the specified Android SDK path. In this line, replace<Username>with your actual username. - Save and Exit
- Press Ctrl+O to write the changes, then press Enter.
- Press Ctrl+X to exit Nano. These commands save the changes and exit the editor.
- To verify if the path is configured, run the following command in the Terminal window:
This command prints the value of the
echo $ANDROID_HOMEANDROID_HOMEvariable in the terminal. - After saving and exiting, close and reopen the Terminal to ensure that the path is set permanently.
- Upon opening a new terminal session, run the
echo $ANDROID_HOMEcommand again to check if the variable is still set. If the path is displayed correctly without any reconfiguration, it indicates that the setting is persistent across terminal sessions. - Upon setting the environment variables, you can open the Appium Inspector, specify the desired capabilities (configuration settings for your test), and start a testing session.
- Upon opening a new terminal session, run the