Sugeivan Senthinathan
Sugeivan Senthinathan

Reputation: 13

Build failed with an exception in React Native android

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.

Upvotes: 1

Views: 1432

Answers (2)

Pavneet_Singh
Pavneet_Singh

Reputation: 37414

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

Upvotes: 1

Chiranjhivi Ghimire
Chiranjhivi Ghimire

Reputation: 1739

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

Upvotes: 0

Related Questions