2

According to the react-native docs, I have installed Android 8.0 (Oreo) and the rest of the instructions. The only difference is that I have defined the path varibales in .bashrc and not .bash-profile. when I want to run my react-native application I face the Build failed with an exception.

the log looks like below:

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. but I already have ANDROID_HOME in the Path.

$ 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

4

As you mentioned local.properties not exist by default and you should add it to project.

  1. Go to your React native Project -> Android
  2. Create a file local.properties
  3. Open the file
  4. paste your Android SDK path like below

    in Windows sdk.dir = C:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk in macOS sdk.dir = /Users/USERNAME/Library/Android/sdk in linux sdk.dir = /home/USERNAME/Android/Sdk 

Replace USERNAME with your user name

Now, Run the react-native run-android in your terminal.

Sign up to request clarification or add additional context in comments.

6 Comments

So you mean there is no way that cli recognize the path?
And now I get /bin/sh: 1: adb: not found
or with an ANDROID_HOME environment
@Amir-Mousavi I got it, Now you should define adb path to system environment variables
system variable/ ANDROID_HOME is updated and also sdk is set in local.properties but still shows the error!
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.