SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable
Solution 1
Please follow below steps it work's for me:
- Go to your react-native Project then go to android directory Create a file with following name:
local.properties
- Open the file and paste your Android SDK path like below:
For windows users:
sdk.dir=C:\\Users\\UserName\\AppData\\Local\\Android\\sdk
Replace UserName with your pc user name . Also make sure the folder is sdk or Sdk. In my case my computer user name is Zahid so the path look like:
sdk.dir=C:\\Users\\Zahid\\AppData\\Local\\Android\\sdk
For Mac users:
sdk.dir = /Users/USERNAME/Library/Android/sdk
Where USERNAME is your OSX username.
For Linux (Ubuntu) users:
sdk.dir = /home/USERNAME/Android/Sdk
Where USERNAME is your linux username(Linux paths are case-sensitive: make sure the case of S
in Sdk
matches)
In case if this doesn't work, add ANDROID_HOME variable in "Environment Variables" as C:\Users\USER\AppData\Local\Android\Sdk
Solution 2
The project might be missing a settings.gradle
file. Make sure that file exists from the project you are importing. If not add the settings.gradle
file with the following :
include ':app'
Save the file and put it at the top level folder in your project.
Solution 3
I know this answer is late, but I hope it helps others.
The answer is simple. You have to just copy your local.properties
file to the folder where project is stored and it will work like charm. But remember, it must be placed in the root folder where the project is stored.
Solution 4
Please follow bellow points it work's for me:
- Go to your
Project -> Android
- Create a file
local.properties
- Open the file
Paste your Android SDK path depending on the operating system:
4.a Windows
sdk.dir = C:/Users/USERNAME/AppData/Local/Android/sdk
4.b Linux or MacOS
sdk.dir = /home/USERNAME/Android/sdk
Replace
USERNAME
with your user name
Solution 5
Check out in your local.properties file
sdk.dir=C\:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk
properly write this format, and also check / slas using for path

Sameer Shamsudeen
Updated on July 08, 2022Comments
-
Sameer Shamsudeen 11 months
I recently tried to import sample Android games I downloaded from Google's developer website. After importing them into Android Studio, I'm getting the following error:
Error: SDK location not found. Define location with
sdk.dir
in the local.properties file or with anANDROID_HOME
environment variable.What is this? I want to run the sample programs from Android Studio.
-
Sameer Shamsudeen over 8 yearsI edited local.properties with this sdk.dir=C:\\Users\\sameer\\Android\\adt-bundle-windows-x86-20140702\\sdk, any error in this
-
Qutbuddin Bohra over 8 yearsyeah after C put \ ... Svae with thishope done. sdk.dir=C\:\\Users\\sameer\\Android\\adt-bundle-windows-x86-20140702\\sdk
-
George Papatheodorou almost 8 yearsThis works nice with eclipse. Just create the file local.properties within the downloaded project and paste the sdk.dir . In my case it was : "sdk.dir=C\:\\adt-bundle-windows-x86_64-20140321\\sdk"
-
pblead26 almost 7 yearsBut I have to copy it everytime? This seems like a hack than the correct approach
-
Harsh Mittal almost 7 yearsIts is the most easy solution for this problem as you dont have to change anything in project. There are also other solution in which you have to do change in code , but I think for such issue one cannot afford to waste much time.
-
Tot Zam over 6 yearsHow can I tell if my project is missing
settings.gradle
? Where is that file usually stored? Where do I typeinclude ':app'
? What exactly doesinclude ':app'
do/generate? Can you please add more detail to your answer? -
Joseph over 6 years@TotZam its stored in the root of your project
-
Tot Zam over 6 yearsFound it. Thanks. For future reference, where would I run
include ':app'
? I'm quite new to Android and trying to find my way around. -
Joseph over 6 yearsYou don't run
include :app
, if you are using Android Studio, that lets Android Studio add your project module so you can run it without further configuration. After you add the line insettings.gradle
you will notice thePlay
button becomes active after gradle finishes building and downloading packages -
Priyank Patel over 6 yearsPut your project folder name instead of 'app' if it's different. It works.
-
user1147171 over 6 yearsThis worked for me when I had this issue after downloading ExoPlayer 2.1.
-
Vinay Vissh over 6 yearsThanks a lot! It helped in importing MPAndroidChart Example which was just stuck at this error :P
-
yashhy about 6 yearsif anyone facing You have not accepted the license agreements... error after the above step see here stackoverflow.com/a/41078173/1778834
-
yashhy about 6 yearsif anyone facing You have not accepted the license agreements... error after the above step see here stackoverflow.com/a/41078173/1778834
-
Rohan Gala about 6 yearsI have installed android on my windows 10 m/c but there is no such folder sdk.dir=C\:\\Users\\USERNAME\\AppData\\Local\\Android?
-
Mayur Baldha about 6 yearsMy android SDK is in D:\Tools\Android\ directory not in C:\ setting sdk.dir=D:\Tools\Android Doesn't work.
-
cesarsicas almost 6 yearsIt works, but Shouldn't Intelij generate this automatically ? tks !
-
rommex almost 6 yearsThis does not work for me. The file is present, but I still have the error
-
Avi Cherry almost 6 yearsThis is often a symptom of attempting to open a project that's not standalone and relies on a parent project. So while this answer is correct, in some circumstances it won't help because most Android projects are reliant on a parent gradle project to for essential configuration.
-
Val about 5 yearsThis corrected the issue on both the mac High Serria and Windows 10. Great answer and efficient.
-
soshial about 5 yearsThis is the only thing that helped me. Steps #3 and #4 are very important
-
cabanni almost 5 yearswhat kind of content should be in the settings.gradle file?
-
user25 almost 5 yearsyes it was in sample folder not in project root, thanks!
-
Arhat Baid almost 5 years@cabanni settings.gradle just includes the module in your application. By default it'll be 'app' module. Hope it helps/
-
Martijn over 4 yearsI already had an ANDROID_SDK which points to the same dir, so for me it was
ANDROID_HOME=$ANDROID_SDK
-
macmuri about 4 yearsThis error is also related with OS language(!!!). If you are using a OS language other than english than try to convert your OS language to english, I am sure it will work. This is only for Windows.
-
Michal Vician about 4 yearsThis helped. After "Re-import Gradle Project" was launched, the following 2 errors were printed to console which helped me to detect the problem: Invalid Gradle JDK configuration found, Project JDK is not specified. So everything started to work after I fixed the JDK path in Settings.
-
Michal Vician about 4 yearsAfter JDK path was fixed I also had to restart the IDE with "File > Invalidate Caches / Restart ..." option.
-
Samuel Owino almost 4 yearsThis gives me " Plugin with id 'com.android.application' not found."
-
Joseph almost 4 yearsThis seems to be a gradle issue, did you try this github.com/udacity/ud839_Miwok/issues/87
-
MING WU almost 4 yearsjust open the android folder by android studio, when android studio opens the 'android' folder, local.properties will be created automatically.
-
Nauman Moazzam over 3 yearsIt is too late to comment, but i want to know how to do that in MacOS?
-
Innocent over 3 yearsi am working with open cv what should i do to add NDK?
-
Erik Sillén over 3 yearsThanks a lot! Had everything else set up but this was missing. A bit weird that Android Studio doesn't give a more understandable error.
-
Alexei Martianov over 3 yearsIt helped. Actually this solution is hinted in the error wording itself. I use IntelliJ on Mac and in project structure I have SDK correct path. Why still do I need that in local.properties then?
-
Shuvo over 3 yearsin MacOS you need to do same procedure just you need to find your Android SDK file path and paste it local.properties file...that's it
-
grc about 3 yearsAfter adding sdk.dir path and also to ~/.bashrc, nothing worked. But then I closed and opened again and it worked. Thanks!
-
groo almost 3 yearsThis worked for me using IntelliJ with Android support installed.
-
Manish over 2 yearsthis answer is so underrated. I've come here twice now and it solved both the times. thanks a lot.
-
Md Shahnawaz over 2 years
-
Shishir Shetty over 2 yearsRESTART is the key.
-
JSON derulo over 2 yearsIf anyone is trying to run one of the samples in the facebook-android-sdk, this tip helped me run it. Loading only one of the examples doesn't work.
-
Anton Plebanovich about 2 yearsI just went to
File > Project Structure
and it said that SDK location is incorrect and fixed it for me on MacOS -
Kimanthi K. almost 2 yearsThis is the answer bro. Big Up maaan!
-
Admin over 1 yearYour answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
-
Lama over 1 yearin windows it should be with double slashes like this sdk.dir = C:\\Users\\USERNAME\\AppData\\Local\\Android\\sdk
-
jave.web about 1 yearif you're using
eas build
(expo build
has been deprecated), this is no longer working, and you have to define the env variable ineas.json
, also the path to the android SDK may be different (I don't have it in my home directory) -
jave.web about 1 yearEAS builds: use
eas.json
under build => production (or other mode) make sure you have{ "env": { "ANDROID_SDK_ROOT": "/your/path/to/androidSDK" }
-
InsaneCat 12 monthsWorking Solution :)