1

Following the react-native docs, I have installed Android 8.0 (Oreo) and have completed the rest of the instructions. The only difference is that I have defined the platform variables in .bashrc and not .bash_profile.

When I want to run my react-native application, I get the error message: Build failed with an exception.

Here are the relevant log messages:

sudo react-native run-android
Starting JS server...
Building and installing the app on the device (cd android && ./gradlew installDebug)...
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

The project built for me does not contain the local.properties file; but, I already have the variable ANDROID_HOME in my path as shown below:

$ printenv | grep Android
ANDROID_HOME=/home/amir/Android/Sdk
PATH=/home/amir/Android/Sdk/tools:/home/amir/Android/Sdk/tools/bin:/home/amir/Android/Sdk/platform-tools:/home/amir/Android/Sdk/emulator

1 Answer 1

1
  1. Open your React Native app directory.
  2. Navigate to your-app/android/
  3. Create a simple text file and call it local.properties
  4. Add the following code to this file (Don’t forget to replace “your-username” with your actual username.):

    sdk.dir = /Users/your-username/Library/Android/sdk

  5. That’s it! run “react-native run-android” command again or use Android Studio to run the project.

1
  • thanks, I did totally forget about this question, apparently, react-native specifically looks for .bash_profile and reads from it. so I created that and added an if condition in .bashrc to load it, and everything worked fine Mar 15, 2019 at 8:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .