SDK location not found. Locate with sdk.dir in the local.properties file or with the ANDROID_HOME environment variable

I recently tried to import sample Android games that I downloaded from the Google developer site. After importing into Android Studio, I get the following error:

Error: SDK location not found. Locate using sdk.dir in the sdk.dir file or with the ANDROID_HOME environment ANDROID_HOME .

What is it? I want to run sample programs from Android Studio.

+204
android android-studio
Dec 23 '14 at 12:20
source share
31 answers
  • one
  • 2

The project may not have the settings.gradle file. Make sure the file exists from the imported project. If you do not add the settings.gradle file with the following:

 include ':app' 

Save the file and place it in the top-level folder in your project.

+226
Feb 29 '16 at
source share

Please follow the steps below, this works for me:

  • Go to your own Response project, then go to the Android directory. Create a file with that name.

local.properties

  • Open the file and paste the path to the Android SDK as shown below:

For Windows users:

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

Replace UserName with your computer name. Also make sure the folder is an SDK or SDK. In my case, my computer’s username is Zahid, so the path looks like this:

 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 S case in Sdk same)

If this does not work, add the ANDROID_HOME variable to the "Environment Variables" as C:\Users\USER\AppData\Local\Android\Sdk

enter image description here

+163
Jan 08 '18 at 18:09
source share

I know this answer is delayed, but I hope this helps others.

The answer is simple. You just need to copy the local.properties file to the folder where the project is stored, and it will work like a charm. But remember that it must be placed in the root folder where the project is stored.

+148
May 21 '16 at 16:10
source share

This problem occurs when you try to import an Android Studio project from the file ../app/build.gradle .

Import the project by selecting the ../build.gradle file located in the root directory of your project.

+37
Nov 22 '17 at 14:50
source share

Check in your local.properties file

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

write this format correctly, and also check / slas using for the path

+33
Dec 23 '14 at 12:43
source share

Here is the work on the problem when you click "Run the application" (green arrow) and get ** Error:

Select the Android SDK ** in the Change Configuration dialog box.

Open

  • File /Settings/Appearance and Behavior/System Settings/Android SDK
  • Look at the top Location Android SDK : path to your SDK Change
  • Click the Edit button
  • Click Next, Next, Finish to accept the default values.

This seems to save the location of the SDK - although nothing has changed - to the internal location. I checked the .idea and .gradle , but did not see what Studio did to modify the configuration file, but now I can run the application.

And summarize previous fixes - this is usually normal for a repo without build problems:

  • the local.properties file is copied to the Studio root folder

  • The path in the local.properties file has the correct path to the Android SDK. In my case, this is sdk.dir=C:\\android\\sdk (note that this path has a different format - Studio should write this file for you based on the text input field in the Android SDK settings dialog box)

    File
  • settings.gradle is present in the repo - and refers to the application folder (usually: application)

+25
Aug 24 '17 at 15:38 on
source share

Please follow below, it works for me:

  • Go to Project -> Android
  • Create local.properties file
  • Open file
  • insert your Android SDK as below:

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

Replace USERNAME with your username

+22
Jul 12 '17 at 11:32 on
source share

On Linux:

If you have already downloaded the Android SDK, but could not find it.

The problem may be that the local.properties file must be inside the same directory as gradle stuff for gradle in order to find it when creating and running adb.

For my project with answers using gradle I needed to put the local.properties file in the Myprojectname/android/ folder.

Since I unzipped the Download SDK, so I just use this path in a file with this line:

 sdk.dir=/home/USER/Downloads/android-sdk-linux 
+11
May 03 '16 at 10:58
source share

I solved this problem by creating the ANDROID_HOME environment variable as indicated in the windows.

 ANDROID_HOME=C:\Users\<user_name>\AppData\Local\Android\sdk 

Restart Android studio, it should build a project!

+9
Apr 27 '17 at 13:10
source share

If you are trying to run a sample Google android code, try importing the entire repository instead of a separate sample .

Here is the relevant section from the .html instructions included in the sample Google Calendar API code

  • Import calendar-android-example project
    • Choose Import Project ... or File> Import Project ...
    • Select [someDirectory] /google-api-java-client-samples/build.gradle and click OK.
      • Note: this will not work if you try to import [someDirectory] /google-api-java-client-samples/calendar-android-sample/build.gradle
    • Select "Use local distribution of Gradle" with "Gradle home" in [someDirectory] /gradle-2.2.1 and click OK.
+8
May 08 '16 at 5:46 a.m.
source share

There is no reason for this error.

  • settings.gradle may be missing or the content in it may be incorrect.
  • local.properties may be missing or the sdk path may be spelled incorrectly.
+5
May 11 '17 at 5:15 a.m.
source share

Just delete the .idea folder and import the project again. It worked for me.

+4
Mar 28 '17 at 7:07
source share

create a local.properties file in the root directory of your project with the following contents

 ## This file is automatically generated by Android Studio. # Do not modify this file -- YOUR CHANGES WILL BE ERASED! # # This file must *NOT* be checked into Version Control Systems, # as it contains information specific to your local configuration. # # Location of the SDK. This is only used by Gradle. # For customization when using a Version Control System, please read the # header note. #Tue Oct 24 17:40:53 CEST 2017 sdk.dir=/Users/****/Library/Android/sdk 
+2
Oct 24 '17 at 20:31 on
source share

the best and easiest way is to create a new Android project, move the "app" folder from the non-working project to the new one and add the necessary dependencies to the gradle of your new project, and everything will work fine)

+2
Mar 12 '18 at 16:51
source share

put these two lines in your .bashrc file and run source ~/.bashrc

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

For Linux, I did it. (For the first line)

 export ANDROID_HOME=/home/$USER/Android/Sdk 
+2
Oct. 14 '18 at 5:38
source share

If you have this problem when you pull your own project, you just need to open the Android project using Android Studio. Everything you need will be created automatically.

  • Open Android Studio
  • File β†’ Open
  • Select the android folder in the folder of your jet project
  • Wait for AndroidStudio to complete the setup.
  • Now you can close Android Studio

OR

If you installed the AndroidStudio command-line launcher :

  • Run this in your responsive root folder
 studio android/ 
  • Wait for AndroidStudio to complete the setup.
  • Now you can close Android Studio
+2
May 11 '19 at 10:38
source share

For Mac / Linux Users

You need to add ANDROID_HOME to your path, add the following to your .bashrc ||.zshrc ||.profile .bashrc ||.zshrc ||.profile file

 # change $HOME to the path where you installed android Sdk export ANDROID_HOME=$HOME/Android/Sdk export PATH=$PATH:$ANDROID_HOME/tools 

Then run

 $ source ~/.bashrc || .zshrc || .profile 

Environment variables in bash_profile or bashrc?

Difference between .bashrc and .bash_profile

+2
Jun 17 '19 at 9:11
source share

Found a working solution for me. Without adding local.properties and setting ANDROID_HOME variable. Looks like a bug in Android Studio and Intellij IDEA. You just need to set the IDE to "reset" the path to the Android SDK. "Location SDK not found" in Android Studio, despite the correct environment settings

+1
Aug 03 '17 at 9:25
source share

I got this error after fresh repository cloning. I expected local.properties to be generated automatically, but that is not the case. I was able to generate it by re-importing the Gradle project.

 File > Re-import Gradle Project 
+1
Feb 20 '19 at 15:40
source share

If local.properties , copy the local.properties file to the project root directory. Simply.

+1
Feb 21 '19 at 7:38
source share

Anyone using jenkins can get this

You need to define the name of the global variable ANDROID_HOME with the value of the path to the Android SDK.

For Mac, it's /Users/YOUR_USER_NAME/Library/Android/sdk

+1
Mar 31 '19 at 7:51
source share

I thought your setting.gradle file was missing. Copy this file to another project and paste your project. I think it will work.

in setting.gradle file,

 include ':app' 

that's all. Have a nice day.

+1
Jul 30 '19 at 14:52
source share
  1. Go to your native React project -> Android
  2. Create a local.properties file

  3. Open file

  4. insert your Android SDK path as 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 
  5. Replace USERNAME with your username

  6. Now, run responsive native run-android in your terminal

or

Sometimes a project may not have the settings.gradle file. Make sure the file exists from the project you are importing. If not, add the settings.gradle file with the following:

  include ':app' 

Save the file and place it in the top-level folder in your project.

+1
Aug 31 '19 at 11:41
source share

I ran into the same problem but a slightly different error message

SDK location not found. Determine the location using the ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project the local properties file to "xxx"

MAC & ReactNative

Add local.properties

  1. Find Android SDK Location

     /Users/yourMacUserName/Library/Android/sdk 
  2. Create local.properties under rootProject/android/local.properties .

  3. Add SDK path to it

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

This usually works, but if you work in a team with other team members, then yourMacUserName is different.

OR

Set the ANDROID_SDK_ROOT variable

  1. Edit ~/.zshrc or ~/.bashrc or ...
  2. Add SDK path:

     export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk 
  3. Open a new terminal tab or source ~/.zshrc
  4. echo $ANDROID_SDK_ROOT to check if the SDK print path is correct.

In addition, you can also add your own path export PATH=${PATH}:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools use some useful commands.

+1
03 Sep '19 at 3:49
source share

Check 1. In the module settings, regardless of whether the location of the SDK. 2. If yes, check the local.properties file (not the one located inside the application module, but the one located outside the application module at the parent level). If not, add it with the bottom lines inside.

 sdk.dir=/path/to/sdk/../Android/Sdk 
0
Apr 24 '17 at 6:52
source share

I only ran into a problem when I cloned my ./gradlew clean assembleDebug with Github and ran ./gradlew clean assembleDebug . I confirm that there is ANDROID_HOME in my .bashrc file.

So, I imported the project into Android Studio. I noticed that the extension of my settings.gradle file is .kts , settings.gradle.kts . When I finished importing, I ran ./gradlew clean assembleDebug and didn't get any problems.

0
Feb 05 '18 at 3:46
source share

I did my best

 sdk.dir = \Users\OLUWAGBEMIGA\AppData\Local\Android\sdk 

and it worked, I just pasted it into the project folder and outside.

In the environment variable, I also used the sdk link above and the name ANDROID_HOME as the path name. Close everything, open it again and Cabom it all works

0
Mar 14 '18 at 23:22
source share

I also find my solution. I just sync Gradle I have all the folders ( settings.gradle,.. ), but I accept this error ... I just SdkLocation Sync Project With Gradle File and edit SdkLocation And everything will be alright ...

0
Sep 30 '18 at 9:54
source share

This solution actually works for me .. go to this computer β†’ properties β†’ additional system parameters β†’ environment variables β†’ then create a new variable in the system variable with the name ANDROID_SDK_ROOT and the value C: \ Users {USERNAME (replace it with your username} \ AppData \ Local \ Android \ Sdk

and make sure that if true Android mobile using USB debugging is turned on. (very important)

then close cmd and restart it.

0
Jul 17 '19 at 16:16
source share

In my case, I had to close Project and open again. It worked fine. Like this

Close project

enter image description here

And open the project again

enter image description here

0
Jul 25 '19 at 7:34
source share
  • one
  • 2



All Articles