Setting up the Android Development Environment Variable for Mac OS

Modified on Tue, 30 Jan 2024 at 09:03 PM

The following instructions are for setting up the Android development environment by configuring the ANDROID_HOME environment variable, which is important for Appium, an open-source tool for automating M-App testing on mac operating systems.


Pre-requisite
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 StudioInstall 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:

  1. To run the nano ~/.bash_profile command on a Mac:
    1. 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").

    2. Run the Command:
      In the Terminal window, type nano ~/.bash_profile and 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.

  2. In the Nano text editor, update your Android SDK path by running the following command: 
    export ANDROID_HOME=/Users/<Username>/Library/Android/sdk


    This line sets the environment variable ANDROID_HOME to the specified Android SDK path. In this command, replace UserName with the actual username.

  3. Save and Exit

    1. Press Ctrl + O to write the changes, then press Enter.

    2. Press Ctrl + X to exit Nano.
      These commands in the nano text editor are used to save the changes and exit the editor.


  4. To verify if the path is configured, run the following command in the Terminal window: 
    echo $ANDROID_HOME 
    This command prints the value of the ANDROID_HOME variable in the terminal.

  5. After saving and exiting, restart your terminal and reopen it to ensure that the path 

    is set permanently.

    1. Upon opening a new terminal session, run the echo $ANDROID_HOME command 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.

    2. 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.






Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article