Resolving the “SDK Location Not Found” Error in React Native

Resolving the "SDK Location Not Found" Error in React Native

6 June 2024 Stephan Petzl Leave a comment Tech-Help

When building a React Native project for Android, one common error developers encounter is the “SDK location not found” message. This error typically indicates that the build system cannot locate the Android SDK. Fortunately, resolving this issue is straightforward. In this guide, we will walk you through the steps to fix this error on different operating systems.

Step-by-Step Solution

For macOS Users

  1. Navigate to the android/ directory of your React Native project.
  2. Create a file named local.properties.
  3. Open the file and add the following line, replacing USERNAME with your macOS username:
    sdk.dir = /Users/USERNAME/Library/Android/sdk

For Windows Users

  1. Navigate to the android/ directory of your React Native project.
  2. Create a file named local.properties.
  3. Open the file and add the following line, replacing USERNAME with your Windows username:
    sdk.dir = C:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk

For Linux Users

  1. Navigate to the android/ directory of your React Native project.
  2. Create a file named local.properties.
  3. Open the file and add the following line, replacing USERNAME with your Linux username:
    sdk.dir = /home/USERNAME/Android/Sdk

Alternative Method: Setting Environment Variables

If you prefer not to create a local.properties file, you can set environment variables to specify the SDK location.

For macOS and Linux

  1. Open your terminal and edit your profile file:
    nano ~/.bash_profile
  2. Add the following lines, replacing USERNAME with your username:
    export ANDROID_HOME=/Users/USERNAME/Library/Android/sdk
    export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
  3. Save the file and apply the changes:
    source ~/.bash_profile

For Windows

  1. Open the System Properties and navigate to Environment Variables.
  2. Create a new system variable:
    • Variable name: ANDROID_HOME
    • Variable value: C:\Users\USERNAME\AppData\Local\Android\sdk
  3. Edit the PATH variable to include:
    %ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

Additional Resources

For more detailed instructions, you can refer to our documentation on virtual test devices and continuous integration.

Streamlining Your Development Workflow

While setting up your development environment is essential, maintaining an efficient workflow is equally important. This is where tools like Repeato come into play. Repeato is a no-code test automation tool for iOS and Android that helps you create, run, and maintain automated tests for your apps quickly and efficiently.

With Repeato, you can focus on building your app while delegating test automation to non-technical colleagues or QAs. The tool leverages computer vision and AI to ensure your tests are robust and easy to manage. Learn more about how Repeato can streamline your development process by visiting our documentation and blog.

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