By Pyae Sone Nyein


2015-09-17 15:30:13 8 Comments

I have error when i start running android

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.

24 comments

@Hitesh Sahu 2019-02-12 09:42:53

Updated steps for React Native0.58 to get started on MAC/Unix

  • Open bash_profile in terminal

nano ~/.bash_profile

export ANDROID_HOME=$HOME/Library/Android/sdk export

PATH=$PATH:$ANDROID_HOME/emulator export

PATH=$PATH:$ANDROID_HOME/tools export

PATH=$PATH:$ANDROID_HOME/tools/bin export

PATH=$PATH:$ANDROID_HOME/platform-tools

Control+S to save
Control+X to exit
Y to save changes
  • Update changes in terminal

source ~/.bash_profile

  • Validate Path:

echo $PATH

  • Confirm if all okay:

adb devices

@Nouman Ghaffar 2019-01-09 11:46:32

If you create and android studio project, You can see a local.properties file is created inside your project root directory. When you create a react native project, It doesn't create that file for you. So you have to create it manually. And have to add skd dir to it. So create a new file inside android folder ( on root ). and put your sdk path like this sdk.dir=D\:\\Android\\SDK\\android_sdk_studio . Remember: remove single \ with double. Just like above.

@Peter Hassaballah 2018-12-02 13:11:51

In your Project Directory there is a folder called "android" and inside it there is the local.properties file . Delete the file and the build should run successfully

@Sajjad Ashraf 2016-03-17 18:51:33

If you are on windows escape (add backlashes to) the backslashes and the colon in the android/local.properties file. If its not there then create it

sdk.dir = C\:\\Android\\sdk

@Stephane 2016-07-27 15:27:04

For Windows, the Android SDK is under C:\Program Files \Android\android-sdk

@Naveen T P 2017-04-26 06:36:55

  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.

@ruelluna 2017-04-28 07:30:09

I moved my SDK to my external drive. Works for me using macOS Sierra.

@ebin 2017-10-05 07:59:48

in linux sdk.dir=/home/USERNAME/Android/Sdk

@Naveen T P 2017-10-05 15:54:06

Thanks @ebin. Updated the answer.

@MarcoZen 2018-01-13 18:59:31

sdk.dir = /home/USERNAME/Android/Sdk -> works for linux but Android Studio for Linux needs to be present and working ( gradle running )

@Chandni 2018-06-14 10:53:02

Showing error* What went wrong: A problem occurred configuring project ':app'. > The SDK directory '/Users/chandni sharma/Library/Android/sdk' does not exist.

@a_rahmanshah 2018-07-01 12:15:05

@Chandni Make sure you have Android SDK installed

@Chandni 2018-07-02 09:11:08

yes it is installed in my machine.

@Sleeping_Giant 2018-09-07 21:09:06

This worked for me. Thank you!

@Taslim Oseni 2018-11-20 13:29:44

Worked like a charm made in my country.. Thanks! :D

@Ravin 2015-09-17 21:19:53

  • Go to the android/ directory of your react-native project
  • Create a file called local.properties with this line:

    sdk.dir = /Users/USERNAME/Library/Android/sdk
    

    Where USERNAME is your OSX username

@Pyae Sone Nyein 2015-09-18 07:31:37

* What went wrong: A problem occurred configuring project ':app'. > The SDK directory '/usr/local/android-sdk ' does not exist. But actually my sdk is exist in this path

@Thomas 2015-09-19 20:12:17

@PyaeSoneNyein have you solve your issue? I'm facing exaclty the same..

@Gasper Kolenc 2015-10-12 12:23:16

Did you guys fix this issue? I'm also facing this right now.

@Max Baldwin 2015-11-10 18:55:28

This worked for me.

@GantMan 2016-02-01 16:39:13

I was able to fix this by running from Android Studio. Once you've done that it works from the command-line.

@Sanj 2016-02-16 01:40:57

Yeah creating that local.properties did solve my issue. Strange but works.

@Razze 2016-08-31 23:05:06

If your on windows sdk.dir = C:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk

@Rohan_Paul 2016-11-20 22:04:14

This perfectly worked for me.

@Yang 2016-12-27 01:06:07

This is perfect!

@Nagarajan Shanmuganathan 2017-01-04 12:13:21

This works! Not sure why this answer is not in the top of the answers!

@Cole 2017-01-23 02:56:56

also make sure you have the android SDK installed developer.android.com/studio/index.html, if that's not obvious :)

@msecilmis 2017-03-24 23:51:58

this should be marked as accepted

@jhenriquez 2017-04-14 05:53:46

I'm on linux and I have the ANDROID_HOME environment variable set. It's weird I still have to do this. It did work though, thanks.

@MD Ashik 2017-04-21 21:11:50

C:\Users\kalam\AppData\Local\Android\Sdk it work for me

@Im Happy 2017-08-13 14:58:08

Hi, I'm new. May I know create what kind of file and name it local.properties ? txt or other format ?

@pixel 2017-08-29 05:39:57

this has fixed issue for me and I am able to issue react-native run-android which will install app on both emulator and real device when one is connected. Thank you so much!

@angryITguy 2017-10-13 02:54:03

Well done.. BTW This should be in the <deity>God!</deity> damn documentation..

@JavaBanana 2017-12-24 10:48:56

Is there a way not to do this every time ?

@felixwcf 2018-03-02 04:00:03

Check if your local.properties file format is not .txt or .rtf. It is .properties.

@Yosvel Quintero 2018-03-21 12:09:47

This perfectly worked for me in Ubuntu 17.10

@JSONParser 2018-04-12 06:10:00

is there any way the local properties folder gets added by default , when starting a new react project , like in android studio it gets added automatically .

@Morton 2018-05-18 04:31:32

This worked for me in Mac.

@Nunchucks 2018-06-04 21:26:31

worked for me on mac

@mehulmpt 2018-06-26 17:10:08

A note to people who're editing this to exclude /Users/USERNAME: sdk.dir expects to be started with /, it doesn't take ~ as home directory

@Khurshid Ansari 2018-07-17 06:44:13

is there any permanent solution for mac os?

@Francois Nadeau 2018-08-30 16:13:56

You should set the ANDROID_PATH instead of setting it in local.properties. Doing so will make it a permanent solution across all your projects, and will not cause problems to other dev in the team should the local.properties file get placed in a code revision tool.

@Nilesh 2018-09-19 15:43:04

Very late, very inexperience but: sdk.dir=$HOME/Library/Android/sdk

@itzo 2018-10-09 08:16:52

This solved the error. Inside the project folder, I created the new file local.properties and added the line you mentioned with my Mac username.

@Pratik Khadka 2019-02-03 11:01:52

This error would specially appear if you have copied the project or downloaded the zip file . It woun't appear if it's a new project or it's been cloned from git

@Keivan 2018-04-12 15:09:34

If you are using Ubuntu, just go to android directory of your react-native project and create a file called local.properties and add android sdk path to it as follow:

sdk.dir = /home/[YOUR_USERNAME]/Android/Sdk

@Ozesh 2018-04-05 10:12:10

For Windows Users

One simple solution is to set the SDK path to the Enviroment Variables list.

  1. Head over to the Enviromnent variables. (Your PC > Properties )
  2. Create New System variables
  3. Set the Variable name to ANDROID_HOME
  4. Set the Variable value to your Android Sdk Location
  5. Press OK (3 times for 3 dialog boxes)

Note:

You Android Sdk is generally located in

C:\Users\YourUserName\AppData\Local\Android\Sdk

Make sure to close your current terminal because your terminal holds all of your pre-existing Environment Variables.

@Rasoul Miri 2018-03-31 14:13:51

Just open folder android in project by Android Studio. Android studio create necessary file(local.properties) and download SDK version for run android needed.

@locropulenton 2018-01-03 20:40:17

DO NOT UPDATE local.properties, it is definitely a bad practice.

This is how I fixed it. Add the following in ~/.bash_profile or ~/.bashrc.

export ANDROID_HOME=/usr/local/share/android-sdk
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/build-tools/23.0.1:$PATH

Note: I used brew cask to install Android SDK following these instructions.

@mike_dz 2018-03-09 02:51:25

Thats the best answer, no need to change local.properties. Works perfect for me

@Dimitri 2018-12-08 16:53:38

It's the bast way, thank you 🎸

@Robbie Milejczak 2019-02-08 16:18:18

why is that bad practice? genuinely curious as it seems like making a localized change is much safer than making a change to your system path

@champika wishwanath 2018-01-10 10:00:40

Copy your system's other android project local.properties and paste in android folder of React-native project it will work.

sdk.dir=C\:\\Users\\paul\\AppData\\Local\\Android\\Sdk

@champika wishwanath 2018-01-10 10:02:36

C\:\\Users\\champika\\AppData\\Local\\Android\\Sdk

@codebased 2017-12-19 07:23:26

The best solution I can find is as follows:

  1. Download Android Studio and SDK of your choice (Even if you think you don't need it trust me that you would need it to release the apk file and some manual changes to the android code).
  2. File > New > Import , point to the location where your react native android project is.
  3. If it ask you to download any specific SDK then please download the same. It can ask you to update gradle etc... Please keep on updating where required.
  4. If you have an existing Android SDK and you know the version then all you have to do is match that version under build.gradle of your android project.

This is how the gradle file will look like:

enter image description here

If everything has gone well with your machine setup and you can compile the project using the Android Studio then nothing will stop you to build your app through react-native cli build android command.

With this approach, not only you will solve the problem of SDK, you will also resolve many issues related with your machine setup for Android development. The import will automatically find SDK location and create local.properties. Hence you don't need to worry about manual interventions.

@notdrone 2016-11-28 07:29:42

Open ~/.bash_profile and add:

 export ANDROID_HOME=~/Library/Android/sdk/
 export PATH=$PATH:~/android-sdks/platform-tools/
 export PATH=$PATH:~/android-sdks/tools/

enter image description here

@Raptor 2017-08-16 03:39:46

Works. Remember to restart Terminal, or type source ~/.bash_profile to make new export lines take in effect.

@P.Ranjan 2017-02-04 16:52:36

There are two gradle files, change the one inside your C:\myapp\android\build.gradle and not in the parent directory myapp.

Replace 23.0.1 with your version of Android Build Tool installed in my case 25.0.0

Run react-native run-android to see your app in emulator.

@ConnelBLAZE 2016-11-21 00:06:13

On Ubuntu, where you have to get SDK separately from the Android Studio strange the path will work with Android Studio but with React Native, you'll need to create a file name local.properties.

For example inn ~/AwesomeProject/android and insert this line:
sdk.dir=/path/to/sdk/in/your/computer

@Niclas 2017-04-13 02:40:52

This worked for Mac OS Sierra too!

@Utah 2016-09-05 18:42:41

This worked for me .

I am taking Stephen Grider's React Native on Udemy and one of the students posted this in Lecture 50. Pasted verbatim in the command line (w/o '$' of course).

$ export "ANDROID_HOME=/usr/local/opt/android-sdk" >~/.bash_profile

@thexande 2017-04-07 23:11:37

Dont do this. it will result in the error > The SDK directory '/usr/local/opt/android-sdk' does not exist.

@DBrown 2017-01-30 04:06:47

Fixing SDK Path Errors on Linux Distributions


Your project is not finding the SDK set in the Project Settings via the path provided, so the project needs to be pointing in the right direction, and you have a couple options to accomplish this, but let's start by finding the correct SDK folder first.


Finding your SDK


From Package Manager


If you are using a package-based JRE install like Java 8 JRE via a the custom PPA in a Debian-based distribution, or used OpenJDK, the directory will most likely be /usr/lib/jvm/java-8-oracle (or whatever version you have chosen). You can find this path set in the JAVA_HOME environment variable:

$ echo $JAVA_HOME
 /usr/lib/jvm/java-8-oracle

Manual Download


If you have installed via the Java JRE/SDK download, it will be wherever you placed the folder, e.g. /home/username/jdk-8u121_1.8.0 (or something similar).

Scripted installs may even add the SDK to /opt/java-8-oracle, but as of this writing, the Java Install instructions leave the folder placement in your hands.


Android Studio 2.2


Lastly if you are using Android Studio, the SDK is placed where you have set it to place the SDK files downloaded through the Studio's SDK Manager. By going to File > Settings > Appearance & Behavior > System Settings > Android SDK, you can find the SDK location setting at the top with the option to change, and the default folder being ~/Android/Sdk.

Android Studio SDK Path

Setting the SDK Path

Now that we know where the SDK is, it is time to let react-native know.


Option 1: Set with local.properties


This method is very simple, and all that is needed is creating the file local.properties in the following folder, where Project_Folder is the base of your React-Native application:

Project_Folder/Android/App

In your local.properties, you want to set the variable sdk.dir to the path of your SDK folder:

sdk.dir=/home/username/Android/Sdk

While this is the easiest way to remedy the issue, it is not the best, especially if you work with multiple projects. For every project, you will have to create this file for every project, and if the folder changes plan on changing this file for each project's local.properties.

Once the file is saved, rerun the react-native run-android command.


Option 2: Settings Folders with Environment Variables


The other option is to set the SDK folders to the local environment variables that React-Native looks for by default. To do so, we will add the ANDROID_HOME path. As a bonus we can also add our android tools in the same place. We need to add this to rather the .bash_profile or .profile files in our home directory, which are loaded last, so we can make sure that nothing else is overriding the settings we make. Since these are in your home directory, there is no need to edit with escalated privileges.

**$ vim ~/.profile**  (use nano or pico if you prefer)

In the file add the following lines replacing the SDK folder with the one you found above. I will be using the Android Studio folder as an example:

export ANDROID_HOME="~/Android/Sdk"
export PATH=$PATH:~/Android/Sdk/tools:~/Android/Sdk/platform-tools

Save the file, then apply the profile settings:

$ source ~/.profile
$ echo $ANDROID_HOME
/home/dbrown/Android/Sdk

If the Sdk folder shows correctly, congratulations! Re-run your react-native command, and watch the app build process continue forward.


If you still have issues


If for some reason you receive the error "> failed to find target with hash string 'android-23' in: your/sdk/folder, you need to make sure that the project's build version and the version of the SDK installed match (React-Native defaults to 23.0.1). You can find the default version in Project_Folder/android/app/build.gradle, and then searching for buildToolsVersion. You can of course change the version from this file, or in Android Studio go to File > Project Structure to change the Project SDK. I would not suggest changing this version unless you absolutely know what you are doing, otherwise install the SDK version the project is looking for.

@Makvin 2017-01-25 04:37:10

Check out in your local.properties file:

sdk.dir=C\:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk

if the format is proper or not

@hoi 2016-12-08 03:16:28

You must write correct full path. Don't use '~/Library/Android/sdk'

vi ~/.bashrc

export ANDROID_HOME=/Users/{UserName}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools

source ~/.bashrc

@snowcamel 2016-09-15 13:39:48

echo "sdk.dir = /Users/$(whoami)/Library/Android/sdk" > android/local.properties

@GravyPlaya 2016-12-16 23:58:53

This is the safest way as you are not changing any global system files. And for those that dont have that type of admin access to their machine.

@Yash Vekaria 2016-09-02 05:44:21

For Linux Users

Your app is not getting the path of android-sdk, so If you are using linux (ubuntu), than you need to add a file named "local.properties" and save it inside the android folder, which is created inside your app folder.

You need to add below line inside local.properties file, which is the path of your android-sdk lies inside your system inside system in order to run the app.

sdk.dir=/opt/android-sdk/

save and rerun the command react-native run-android

OR

you can open terminal, type

sudo nano ~/.bashrc

and paste the below path at the end of the file

export ANDROID_HOME="/opt/android-sdk/"

and restart your computer and run again react-native run-android after that.

Note:- If you put set path in .bashrc file, then you don't even need to create local.properties file.

@Arel 2016-04-05 18:52:47

Make sure you have the proper emulator and Android version installed. That solved the problem for me.

@Rathore 2016-02-18 08:03:04

Copy your system's other android project local.properties and paste in android folder of React-native project it will work.

@Nish 2015-09-24 17:00:10

You can try adding ANDROID_PATH

export ANDROID_HOME=/Users/<username>/Library/Android/sdk/
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

@GantMan 2016-02-01 16:38:34

this did not work for me

@Jason Guo 2016-12-08 03:24:50

This only works on Linux and Mac

@Paul 2017-05-03 20:05:46

Perfect solution! Although you would think the build would be smart enough check this for you.

@Hesam 2017-08-01 20:40:56

I already have ANDROID_PATH in environment (Ubuntu, .bashrc file). However, for some reasons I am still geting the issue. I fixed it by creating local.properties and putting the path as stated in other answers.

@Faris Rayhan 2018-04-29 06:23:28

Fortunately i use Mac

@Henrik 2019-01-06 14:06:39

I have a mac and env var ANDROID_HOME did not help. local.properties did, however.

Related Questions

Sponsored Content

39 Answered Questions

[SOLVED] Can't start Eclipse - Java was started but returned exit code=13

34 Answered Questions

[SOLVED] Android Studio: Add jar as library?

0 Answered Questions

SDK location not found Error on Android Studio in Mac

1 Answered Questions

[SOLVED] SDK Location not found- Android Studio

  • 2015-12-12 13:12:28
  • Youssef
  • 681 View
  • -2 Score
  • 1 Answer
  • Tags:   java android sdk

38 Answered Questions

[SOLVED] Is quitting an application frowned upon?

  • 2010-01-09 15:59:46
  • Ted
  • 263946 View
  • 1089 Score
  • 38 Answer
  • Tags:   android

3 Answered Questions

[SOLVED] Android Studio SDK Location Not Found

43 Answered Questions

[SOLVED] Update Eclipse with Android development tools v. 23

8 Answered Questions

[SOLVED] Android error: Failed to install *.apk on device *: timeout

Sponsored Content