Resolving “Neither ANDROID_HOME nor ANDROID_SDK_ROOT Environment Variable Was Exported” Error

Resolving "Neither ANDROID_HOME nor ANDROID_SDK_ROOT Environment Variable Was Exported" Error

10 November 2024 Stephan Petzl Leave a comment Tech-Help

Encountering the error message “Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported” can be frustrating when trying to start a session in Appium on a Windows 10 system. This error typically indicates that the system is unable to locate the necessary Android SDK files due to incorrect or missing environment variable settings.

Step-by-Step Guide to Fix the Issue

1. Verify Environment Variables

First, ensure that both ANDROID_HOME and ANDROID_SDK_ROOT are correctly set in your system environment variables. Follow these steps:

  • Open the “System Properties” window by right-clicking on “This PC” and selecting “Properties”.
  • Navigate to “Advanced system settings” and click on “Environment Variables”.
  • Under “System variables”, check if ANDROID_HOME and ANDROID_SDK_ROOT are listed. If not, add them and set their values to the path of your Android SDK installation.
  • Ensure no spelling mistakes occur in the path by copying it directly from the file explorer.

2. Restart Appium

After setting the environment variables, restart the Appium server. It’s often necessary to restart the server in a new Command Prompt window to apply the changes. A previously launched server may continue to show the same error.

3. Check for Conflicting Processes

If the problem persists, it might be due to a conflicting process running on the same port as Appium. Use the following steps to resolve this:

  • Open a Command Prompt and run the command: netstat -ano | findstr :4723 to identify any processes using port 4723.
  • If a process is found, note its PID (Process ID) and terminate it using: taskkill /PID [PID] /F.

4. Verify Configuration on macOS or Linux

For macOS or Linux users, ensure that your shell configuration files (.bashrc or .zshrc) include the correct export statements for these environment variables. You can refresh these settings by running:

  • source ~/.bashrc or source ~/.zshrc, depending on your shell.

Enhancing Your Testing Workflow

While Appium is a powerful tool for mobile automation, it can sometimes be slow and prone to stability issues. If you are seeking a faster and more reliable alternative, consider using Repeato. Repeato is a no-code test automation tool for iOS and Android that leverages computer vision and AI to create and run tests quickly. This tool can significantly reduce the time spent on test creation and execution, offering a streamlined solution for your mobile app testing needs.

Like this article? there’s more where that came from!