43

I have just imported my eclipse project in android studio. it keeps my saying that

Error:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

I have seen some tutorials of editing local.properties files but it didnt work. here is my project.properties file:

sdk.dir=E:\\Mod Eclipse\\adt-bundle-windows-x86_64-20130219\\sdk

Actual directory of my folder is :

E:\Mod Eclipse\adt-bundle-windows-x86_64-20130219\sdk

BST Kaal
  • 2,993
  • 6
  • 34
  • 52
  • [SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable](https://stackoverflow.com/a/37365254/6521116) – LF00 Jul 11 '17 at 05:30

14 Answers14

35

A quick note about this if trying to run a Facebook sample and this error pops up, make sure you select the build.gradle file in the root of Facebook sdk, for all the samples when 'opening an existing project'. I got this error when I tried to open the gradle for just the Scrumptious sample from the 3.22 SDK

letroll
  • 1,059
  • 1
  • 14
  • 36
Daniel Wilson
  • 18,838
  • 12
  • 85
  • 135
  • 4
    I was not opening a Facebook sample but in my case I was trying to open the folder containing the sample. When I opened the gradle file itself the error went away. – nasch Jun 30 '15 at 22:46
  • Same with the [CoRedux sample](https://github.com/freeletics/CoRedux/tree/master/sample), I had to open the CoRedux project in Android Studio and run the sample project from there rather than opening the sample project directly in Android Studio. – Michael Osofsky Nov 18 '19 at 20:43
25

My problem was:

  1. I cloned a project from github
  2. I clicked open existing Android Studio project
  3. I chose the path of the inner sample app instead of the containing folder.

So what you should do is:

  1. close the project.
  2. click open existing Android Studio project
  3. select the parent folder instead of the sample app.
Uriel Frankel
  • 14,304
  • 8
  • 47
  • 69
23

If you are sure that you have assigned correct SDK path in project settings, and you can see it in local.properties as well, but still getting this error then there are chances that you are missing something in you project.

I was getting the same error after looking in to my project I found settings.gradle was missing. enter image description here and then add following script to your apps build.gradle enter image description here You will not face this error any more. It worked for me may be gradle set up was the blocking issue

DeltaCap019
  • 6,532
  • 3
  • 48
  • 70
  • I now have a new different problem, but thanks, this indeed got rid of the SDK location not found error. – Alyoshak Apr 28 '17 at 19:22
  • it solved my porblem but has started another problem saying 'plugin with id' com.android.application not found. Do you have any idea – Abdul Waheed Oct 09 '17 at 06:12
  • @AbdulWaheed google that issue I think it has some gradle version compatibility issue look here https://stackoverflow.com/questions/24795079/error1-0-plugin-with-id-com-android-application-not-found – DeltaCap019 Oct 09 '17 at 07:44
  • @DeltaCap I have solved buddy :) it was gradle file issue – Abdul Waheed Oct 09 '17 at 07:45
14

You should also change it on Project Structure.

  • Close the current project and you'll see pop up with dialog which will then proceed to Configure option.

    Configure -> Project Defaults -> Project Structure -> SDKs on left column -> Android SDK Home Path -> give the exact path as you did on local.properties and select Valid Target.

There you go.

Yogesh Umesh Vaity
  • 41,009
  • 21
  • 145
  • 105
Onur A.
  • 3,007
  • 3
  • 22
  • 37
  • This is in my local.properties sdk.dir=E\:\\Mod Eclipse\\adt-bundle-windows-x86_64-20130219\\sdk – BST Kaal Aug 31 '14 at 21:27
  • and this one is the exact location E:\Mod Eclipse\adt-bundle-windows-x86_64-20130219\sdk – BST Kaal Aug 31 '14 at 21:28
  • it should be single slash not double so in your case not E\:\\Mod Eclipse\\adt-bundle-windows-x86_64-20130219\\sdk, correct: E:\Mod Eclipse\adt-bundle-windows-x86_64-20130219\sdk – Onur A. Sep 01 '14 at 06:28
14

The simplest solution sometimes is just do the File -> Invalidate Cache / Restart.

If it does not help then go for the more complicated stuff, as suggested in other answers

Andriy
  • 707
  • 1
  • 7
  • 16
6

You can add a local.properties with to set the sdk.dir like sdk.dir=/Users/roofe/Library/Android/sdk.

But please note below, which is very important,

add the local.properties to the uppermost path of the project. Here the uppermost have some difference with root path of a project.

For example in the below project, I just use the ijkplayer-example, but this module also used other module with different cpu architecture.

If I only add local.properties to ijkplayer-example will not work. Here will get sdk location issue for other module.

While I can add the local.properties to the ijkplayer directory, then when I try to open the ijkplayer-example project, there will auto create a local.properties for ijkplayer-example, and everything works well.

enter image description here

LF00
  • 27,015
  • 29
  • 156
  • 295
3

In my case, it was a fresh install with checkout from github.

  • Just close the checkout window.
  • Create a new project (not from git, just a fresh one).
  • exit the project.
  • checkout whatever you like

Its just the fastest way that I found.

Idan Magled
  • 2,186
  • 1
  • 23
  • 33
2

Sync project with Gradle files, It will modify the project's local.properties file.enter image description here

1

So I had the same issue, and none of the answers given previously helped me. What I did was check for new API updates (in my case, I updated to API level 23) and the problem was fixed.

O'Kamiye
  • 456
  • 4
  • 6
1

I add just local.properties file where my project is located. In local.properties:

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

such kind of path is there which is our Sdk path.

So just create local.properties file manually and inside this just copy the Sdk file location.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
1

In Android Studio, I just clicked on File and then Choose Project Structure or Ctrl-Alt-Shift+S. This'll clearly show you the Android SDK location and an input box where you can browse to the correct one if it is not correct.

zenphp
  • 11
  • 1
0

Probably local.properties file missing.

Copy a local.properties from an existing file and add it to your current project. That worked for me.

Shafi
  • 1
  • 1
  • 2
0

I installed the SDK again (from here for example :

https://www.mediafire.com/file/azbsqg6dmg7z7np/Sdk+tools+for+android+studio.rar/file

& it created the directory & the packages, after installation.

Now I open android studio & everything is normal.

Jkarhani
  • 3
  • 3
0

Everything posted so far was helpful in an overall learning capacity. However, most of the time, fixing one problem created others. What ended up working for me was completely deleting the GitHub project .zip file and any unzipped files. Then I made sure the correct .zip file was re-downloaded and unzipped. When it came time to open it in Android studio, I noticed there were 2 folders with identical project file names, one being contained in the other. The first (or upper) one is actually the .zip file. Open the other one!