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
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
That’s it! run “react-native run-android” command again or use Android Studio to run the project.