60

Getting this complaint from IntelliJ 13:

8:15:48 PM Gradle '<project>' project refresh failed:
           SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
           Build file '/<project>/build.gradle' line: 20
           : Gradle settings

I have tried to spam my local.properties in every directory I can think of but still getting this error. What gives?

3
  • Have a look here? Dec 19, 2013 at 4:24
  • I tried putting the file in my root directory already, still getting that error :(
    – pfrank
    Dec 19, 2013 at 4:44
  • The local.properties file should be in the root of your project (as indicated in earlier comments here), in the same place as your settings.gradle file. You say you're using IntelliJ 13, presumably with the Android plugin, and not Android Studio? And this is obviously a Gradle-based project. Can you post more details about the directory structure of your project? Also, try building from the command line with the --info and --stacktrace options and post that output. Dec 19, 2013 at 17:09

3 Answers 3

83

The local.properties file goes in the project's root level, in the same folder as the gradlew, gradlew.bat, settings.gradle and other files.

This file should not be included in source control. After (incorrectly) including this in source control, then deleting the file locally, Android Studio re-created the file for me automatically.

Here is the example content of this file:

## 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.
#Thu Aug 14 14:49:26 PDT 2014
sdk.dir=C\:\\Program Files (x86)\\Android\\android-studio\\sdk

Note the sdk.dir= reference to the location of the Android Studio SDK installation (which may be different on different machines).

8
  • 1
    my local.properties is committed into source control. It's weird. Jun 4, 2016 at 5:35
  • 10
    @SaeedNeamati It shouldn't be, as it contains configuration that's specific to a workstation (i.e. not everyone's SDK is going to be installed in the same location, especially if doing cross-platform development)
    – CJBS
    Jun 4, 2016 at 5:39
  • 2
    add it to your .gitignore file. you can put an example.local.properties file in that location.
    – agm1984
    Oct 3, 2017 at 21:55
  • Is this file included when creating APK?
    – Mr. Nacho
    Jan 17, 2018 at 9:52
  • 1
    @Mr.Nacho - this file shouldn't be included, as it's a config file specific to a development workstation, not the output package.
    – CJBS
    Jan 17, 2018 at 17:44
21

For MAC create file local.properties inside android/ and paste this line inside the file

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

3
  • What is the type of the file ?
    – user123456
    Dec 15, 2019 at 0:04
  • FileName: local with extension: .properties Dec 15, 2019 at 3:19
  • work perfect, it was complaining about SDK path and setting the environment.
    – TheTechGuy
    Jun 15, 2021 at 2:42
1

For MacOS, put your file gradle.properties in these 2 places:

  1. ~/.gradle/
  2. /Users/<your_user>/Library/sdk/

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.