48

I am using Android Studio for a project on SVN (usually on Windows PCs).

Lately I want to run this on a Mac, it keep giving the below error:

Error:The SDK directory '/Users/AhmadMusa/Desktop/[PROJECT PATH]/D:\Android\sdk' does not exist.
Please fix the 'sdk.dir' property in the local.properties file.

I already put the SDK on local.properties file as:

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

I don't know why it keep adding the (D:\Android\sdk) automatically, this is my Windows PC SDK directory, but why it is here now! nothing on code mention any D:\Android\sdk.

dpacman
  • 3,683
  • 2
  • 20
  • 35
Ahmad Mousa
  • 745
  • 2
  • 7
  • 18
  • 1
    check if the sdk folder has permissions! – Max Pinto Aug 21 '15 at 21:18
  • @MaxPinto, checked and i have Read & Write permissions :( thanks though. – Ahmad Mousa Aug 21 '15 at 22:45
  • put your full path, are you using windows, linux or Mac. if it is windows, you should put absolute path, if linux/Mac you should use a link if dont want to use full path. Windows full path is: c://users/AhmadMusa/.... as you have – Max Pinto Aug 21 '15 at 22:55
  • This problem is on my Mac as mentioned above. I used to work on this project from a Windows PC, but this is my first time on Mac, and trying to make things running here.. the (D:\Android\Sdk) is the sdk path on my windows PC, but I don't know why it came here on the Mac, where can I find this to delete it? It is not on SDK Location or local.properties or any where else! – Ahmad Mousa Aug 21 '15 at 23:02
  • check my formal answer – Max Pinto Aug 21 '15 at 23:07
  • A key point missed by all of the answers is where this value is coming from for sdk.dir. AndroidStudio creates this file. The value does not come from the ether. It is possible if you have set an ANDROID_HOME value in your environment, you will find the source of this value. In my case, unsetenv ANDROID_HOME (or remove from windows environment) fixes the root cause. – truedat101 Apr 20 '21 at 02:21

29 Answers29

46

Right click your project and select 'Open Module Settings' under SDK Location put your location for your SDK.

paste in /Users/AhmadMusa/Library/Android/sdk

Clean and rebuild your project

Update

Try to delete your local.properties file and create a new one, but do not check it into version control.

Right click top level of project and Create new file 'local.properties' then add: sdk.dir=/Users/AhmadMusa/Library/Android/sdk

Clean and build

kandroidj
  • 13,784
  • 5
  • 64
  • 76
  • 1
    this was already done too, it shows : /Users/AhmadMusa/Library/Android/sdk – Ahmad Mousa Aug 21 '15 at 21:12
  • 2
    Thanks @inner_class7, tried this, still the same.. It gives the error even while cleaning and before anything, just after I press Clean project, I get this: Error:A problem occurred configuring project ':ProjectName'. > The SDK directory '/Users/AhmadMusa/Desktop/[ProjectPath]/D:\Android\sdk' does not exist. – Ahmad Mousa Aug 21 '15 at 22:56
  • @AhmadMusa can you check to see what your local.properties file is in SVN and if the sdk.dir is there? – kandroidj Aug 21 '15 at 23:21
  • 2
    Sorry for this absence. I will pick this as the answer of my question (although I still faced other issues)... I found another local.properties in a parent folder of the project (although it shall not affect I think because it was in a parent folder of the project, but still this file affected the compilation)... My project was on child folder of this parent folder... I faced several other issues after this, solved them one by one, then stopped after fixing my Windows PC (I believe it is more convenient and easier there after the cases I faced in Mac!) Thanks for the assistance though :) – Ahmad Mousa Sep 04 '15 at 22:40
  • Deleting the file helped me – Yossi Mar 09 '19 at 12:31
17

I finally find this file on the disk.The 'local.properties' file in The Android studio is not which you modify.see the picture,so you can modify this line 'sdk.dir' to your dir of sdk.Remember not in the android studio. enter image description here

nihaoqiulinhe
  • 259
  • 3
  • 5
  • You saved my life, thanks. This file also wasn't appearing in Android Studio search for some reason. – Daniels Šatcs Oct 03 '18 at 17:55
  • yeah, this solved my issue, in fact there were 2 local.properties inside my directory, even though I deleted one such file inside Android Studio – Nfff3 Sep 16 '20 at 14:24
8

This is a problem when you open the project incorrectly. open the project do not import the project

Rajendra Verma
  • 439
  • 5
  • 16
8

Create or edit file local.properties under android directory

For window path should be like this

sdk.dir = C\:\\Users\\user name\\AppData\\Local\\Android\\sdk

For linux system path should be like this

sdk.dir = /home/user name/Android/Sdk/
Community
  • 1
  • 1
vinod
  • 2,850
  • 1
  • 18
  • 23
4
  1. Open your project folder
  2. open local.properties in notepad++
  3. change sdk.dir to C:\Users\xxxx\AppData\Local\Android\Sdk
  4. save

After edit, resync again android studio.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
tang sang
  • 41
  • 1
3

I solve this problem, the reason is: You downloaded other's projects. His local.properties file content is his SDK path. You must replace SDK path with your local SDK path, then rebuild the project.

trungduc
  • 11,926
  • 4
  • 31
  • 55
邱林和
  • 41
  • 1
2

From Android Studio 1.0.1

Go to

File -> project Structure into Project Structure Left -> SDK Location SDK location select Android SDK location (old version use Press +, add another sdk) Change the sdk path to /Users/AhmadMusa/Library/Android/sdk

kaka_2
  • 333
  • 3
  • 13
  • 1
    it is already set to the SDK path mentioned above... My concerned point is from where is the D:\Android\sdk came from ?! It is my Windows PC SDK path, why it is here? Searched everywhere and couldn't find it to remove it.. – Ahmad Mousa Aug 21 '15 at 22:51
2

I solved this issue in Windows using this format for the full path:

sdk.dir=C:/Users/xxxx/AppData/Local/Android/Sdk

aleshu
  • 31
  • 4
1

I think you should go to:

File ->Project Structure->SDK Location->

there select your sdk location.

Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
Max Pinto
  • 1,463
  • 3
  • 16
  • 29
1

Just open your local.property file

if your project is used in mac before, so the sdk path will be something like sdk.dir=/Users/siddharthyadav/Library/Android/

Now if you are trying to use that in windows so just edit and put your sdk location: Example: sdk.dir=D:\software\android-sdk\android-sdk

Just clean and build. See it works!!!

Siddharth Yadav
  • 161
  • 1
  • 6
1

Just close your project and re-open it again. Than SDK message appears click ok.

1

Today upgraded to Android 3.3, which broke everything for me.

This one was related to importing the project, not opening it.

Solution which worked for me, was to import the project. During the import it detects that the SDK directory is missing and proposes to open it from a location which actually exists. It worked in my case but your case might be different.

Many other changes still needed to be done to make old projects work. What a pain any update is. I wonder why don't they do a thorough QA first before releasing these updates. It has become an industry norm to release problem filled software, probably thinking that users will figure out solutions via Stackoverflow.

zeeshan
  • 4,913
  • 1
  • 49
  • 58
1

I had the same problem. Just open the project main folder. and then close and reopen the project sub folder app.

Pir Fahim Shah
  • 10,505
  • 1
  • 82
  • 81
1

In my case, my project is located inside another Android project. Therefore, I opened the local.properties of the parent project and fix the sdk.dir's path there.

Yusril Maulidan Raji
  • 1,682
  • 1
  • 21
  • 46
1
  • Select SDK Location: File->Project Structure->SDK Location->
  • Close Android Studio.
  • Remove .gradle and .idea folders, local.properties, all .iml files in the project: <module_name>/<module_name>.iml
  • Open Android Studio and select Open an existing Android Studio project
  • Select path to your project

This way must to help.

Vladislav
  • 1,236
  • 13
  • 22
0

Checkout your SDK manager in Android studio, if you have partially installed sdk. Install SDK completely and try running your code.

0

I had a ; in the environment variable name, put it out and it will works !

  • refollow the steps after the verification of the ANDROID_HOME
  • react init
  • => run you emulator
  • => run-android
Giulio Caccin
  • 2,962
  • 6
  • 36
  • 57
Lauules
  • 1
  • 1
0

sdk.dir didn't work for me because I had ANDROID_HOME environment variable with wrong path. So, solution is just to update ANDROID_HOME or remove it to use local.properties.
Android Studio restart is required after the change.

Anton Balashov
  • 940
  • 1
  • 12
  • 20
0

I faced the same problem - it was solved by only the following step. I deleted all created .idea and .gradle folders. It is the path problem I faced while loading source in SDK, I think.

Bartłomiej
  • 1,068
  • 1
  • 14
  • 23
0

If you have set the ANDROID_HOME variable, just remove or comment that line in local.properties file. It is the solution for me

Hoang Tran
  • 886
  • 3
  • 13
  • 32
0

in latest Android Sudio 3.2.1

1- you will see two files with the name 'local.properties'

2- one will be inside folder named 'app' ( app level folder ), Only if you have not yet been able to sync your project. if you cant see it in the folder strucrure in Android studio then physically find this folder in Finder . (right click and reveal in finder in case you use a MAC machine). Make changes here.

3- and other will be inside 'gradle script' make sure you have same path there . Also make changes here (if you can see this file)

Basically find this file at its physical location in the project folder (physical location ) and make changes

eg. : sdk.dir=/Users/Rakesh/Library/Android/sdk

in both the files .

YogiAR
  • 2,207
  • 23
  • 44
0

My solution: open app on Android studio.

Check sdk and clean App, after rebuild I had fixed this problem by following suggestions of Android Studio. finally run app with react-native run-android/ios

Android
  • 1,420
  • 4
  • 13
  • 23
Thanh Cao
  • 151
  • 5
0

This might due to merge conflict same as mine, try to change local.properties for me it was wrong location for android sdk as it was override from other machine ndk.dir=/Users/???/Library/Android/sdk/ndk-bundle sdk.dir=/Users/???/Library/Android/sdk

then rebuild

0

If your project is a subproject, the problem may lie on the parent local.properties file. I may suggest you to go up in the project hierarchy to the root file and execute the following command:

$ find . -type f -exec grep -l sdk.dir {} \;

That would work on OSX and Linux, if you are in Windows you may need to install Cygnus tools or something akin (I don't use Windows, so I cannot be more precise). If the path is wrongly set in some file, you'll find it with that command, then it is just a matter of opening the file with a text editor and replacing the wrong path with the right one.

Fran Marzoa
  • 4,293
  • 1
  • 37
  • 53
0

My scenario is I open the project, and the local.properies shows my sdk.dir. But it keeps telling me it need the sdk from the previous other user's dir.

So I close the project and re-import the project, and everything works fine.

Francis Bacon
  • 4,080
  • 1
  • 37
  • 48
0

Choose one of the options- OPTION A

  1. Delete the 'local.properties' file in 'Gradle Script'
  2. Create new 'local.properties' file there
  3. Paste this into your new 'local.properties' file sdk.dir=/Users/uttam/Library/Android/sdk

OPTION B

  1. copy the 'local.properties' file from your any old project.
  2. paste this in your new project, you will be asked confirmation, choose 'replace'

HAPPY CODING :)

UTTAM
  • 319
  • 3
  • 4
0

Fix the root cause. If you check the other answers they suggest to find the SDK location property and fix that. Assume you have that correctly set, otherwise you won't have any SDK components downloaded on your system. Then something in your environment is telling AndroidStudio where to find the sdk.dir. Since AndroidStudio will create this local.properties file for you, it is likely first checking the stored property of "Android SDK" System settings for this location. It should use this value in the local.properties. If you find that it still gets the wrong value, the root cause is that AndroidStudio fills the sdk.dir property from ANDROID_HOME, found in the host system environment. Fix this and it fixes the problem. You will need to (1) correctly set ANDROID_HOME or unset the variable for ANDROID_HOME (2) remove the existing local.properties (3) restart your AndroidStudio.

truedat101
  • 76
  • 1
  • 6
0

You need to change sdk.dir='...' in local.properties file as per your sdk location.

For checking sdk location, open File -> Project Structure -> SDK Location. If sdk location is also not correct there, you can also update it.

Samiya Khan
  • 241
  • 3
  • 4
-1
  1. Go to your project_folder/platform/android/
  2. Open local.properties in your text editor
  3. Change URL with your SDK URL sdk.dir = C:\Users/Pcesolutions/AppData/Local/Android/Sdk
  4. Now run your command in windows

Its worked for me. I think, it work's also in your PC.

YASH GAUTAMI
  • 673
  • 1
  • 6
  • 11
Anjani Barnwal
  • 1,362
  • 1
  • 17
  • 23
  • None of the suggested fixes work for me. AS 3.4.1 on Mac OSX 10.14.5. I still get `The SDK directory '~/Library/Android/sdk' does not exist` although it most certainly does and has the correct permissions `drwxr-xr-x Android/` – Mike S. Jun 18 '19 at 19:12
  • sir its for windows only. – Anjani Barnwal Jun 28 '19 at 05:48