1

I am new to React Native. When I run the project using react-native run-android in terminal, Build failed with an exception error will display.

I set android_home (sdk location) correctly:

Error detail

FAILURE: Build failed with an exception.

* Where:
Build file '/home/sugeivan/react/AwesomeProject/android/app/build.gradle' line: 110

* What went wrong:
A problem occurred evaluating project ':app'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
mnille
  • 1,328
  • 4
  • 16
  • 20
  • Possible duplicate of [React Native - java.lang.RuntimeException: SDK location not found. Define location with sdk.dir in the local.properties](http://stackoverflow.com/questions/35141951/react-native-java-lang-runtimeexception-sdk-location-not-found-define-locati) – Waylan Punch Feb 09 '17 at 08:25

2 Answers2

1

Build system need to know the exact location of SDK on your system which contain platform specific tools and source code files to build the project.

seems like your android sdk path is not set in your OS and make sure you have SDK.

  1. if there is no ANDROID_HOME varibale or the sdk path is wrong so to check this

goto control panal=> system =>properties find environment variable option under advance tab and click on it

if not found then you need to set the sdk location path in environment variables by adding a new variable as "ANDROID_HOME" .you can do this in two ways

through terminal follow this link this will create new variable and add it to OS environment variables

and other way is goto control panal=> system =>properties find environment variable option under advance tab and click on it create new under user variable name will be ANDROID_HOME and value will be "path to your sdk folder" e.g C:\android\sdk

  1. if the varible is set then try to add this line in your local.properties file

sdk.dir=C:\android\sdk

Community
  • 1
  • 1
Pavneet_Singh
  • 36,884
  • 5
  • 53
  • 68
  • i am using linux, my path in bash >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>export ANDROID_HOME=/home/sugeivan/Android/Sdk/ PATH="~/Android/Sdk/tools:~/Android/Sdk/platform-tools:${PATH}" export PATH – Sugeivan Senthinathan Jun 22 '16 at 11:12
  • u need to do itlike this export ANDROID_HOME=/home/user/Android/Sdk export PATH=$PATH:/home/user/Android/Sdk/tools from here http://stackoverflow.com/questions/26256279/how-to-set-android-home-path-in-ubuntu-please-provide-the-steps and make sure build.gradle files are there in your project or if nothing works make sure your sdk path is properly set and then try to create a new project, sdk path loc is required many places in project so sometimes gradle can be little goofy if path wasn't set while creating project – Pavneet_Singh Jun 24 '16 at 04:19
0

You should set the environment path as:

   variable name: ANDROID_HOME
   variable value: F:\android\android-sdk

   You need to restart the Command Prompt (Windows) to apply the new environment variables.

  variable value is your android sdk path.

you should also correctly set android studio sdk path by going to:

   1. File
   2. Settings
   3. Android SDK-> Android SDK Location: F:\android\android-sdk
 you should update your SDK libraries as mentioned by the react-native official documentation: 

http://facebook.github.io/react-native/releases/0.27/docs/getting-started.html

Chiranjhivi Ghimire
  • 1,739
  • 1
  • 19
  • 21