chevron_left
600 points
7 3 2

If you've ever come across the following error message in your Android Studio project, you know it's not exactly helpful: 'SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.' Well, this post will tell you how to fix that problem (and explain what the problem is!).

Photo by Irina_kukuts

Table of Content:

                1 - What is Sdk location not found. Define location with sdk.dir in the local.properties 
                2 - Why will this message appear 
                3 - What is the solution 
                4 - The Conclusion

What is Sdk location not found. Define location with sdk.dir in the local.properties

A Software Development Kit (SDK) is a set of tools that may be used to create software. SDK is a collection of tools that allow you to write programs for mobile platforms like Android and iOS. You can download the SDK from: https://developer.android.com/studio/releases/platform-tools and extract/place it in the default folder if one does not exist. The SDK's default location on a Windows PC would be

sdk.dir = C:\Users\UserName\AppData\Android\sdk (here username is the name of your PC)

If you run into this issue, it's likely because the sdk.dir property is not set to an actual SDK location.

This could be due to a number of factors:

The sdk.dir property is not defined at all. If you don't have a local.properties file in your project directory, you'll need to create one and define the sdk path in it like so:

sdk.dir = C:\Users\UserName\AppData\Android\sdk (here username is the name of your PC, if sdk is not installed on root )

Why will this message appear

There may be a number of errors in the code while writing a program or in a project setting, which may be due to the same or different reasons. In this case, the following reasons may be present

  • The path is not set to local.properties file in the project.
  • Local.properties file is missing in the project folder
  • An environment variable is not set to your sdk path.
  • There may be multiple lines local.properties file that also can throw this error message.

What is the solution

It is possible that the different causes that make up an error message all have the same solution and it is also possible that there are different solutions for the same cause.

  • If the path is not set in the local.properties file needs to be set it. You can find this file in your SDK directory under the resources folder.
  • If local.properties does not exist, you will need to create it. You can find this file in your SDK directory under the resources folder. To create local.properties, all you have to do is open a new file in any text editor and rename it with a ~ at the beginning of its name (local~). Then add this code:
    sdk.dir=/path/to/sdk/folder (locate your sdk folder and write its path here)
  • ANDROID HOME should be added to the Environment Variables list. Add a variable by going to System Properties -> Environment Variables -> Add Variable and entering the Variable Name and Value. Add ANDROID HOME as a variable with the value: as your SDK path. If your route isn't in C Drive, you'll need to include the write path for sdk. Make sure you're on the right track. The name of your computer is UserName. and then click OK.          
    sdk.dir=/path/to/sdk/folder (locate your sdk folder and write its path here)
  • The file should contain only one line: sdk.dir=path_to_your_android_sdk . If you have multiple lines, it will create errors. The path is the location of your Android SDK folder which by default is in C:\Program Files\Android\Android Studio v3\sdk (for Windows) or /Applications/Android Studio v3/sdk (for macOS).

If you don't have an Android SDK installed and configured then download one from here:     https://developer.android.com/studio/releases/platform-tools

The Conclusion

Mistakes are good for learning, only those who learn from mistakes are successful. There is an old saying that those who learn from their mistakes are good and successful persons but those who learn from the mistakes of others are not only good and successful but also very good and superman.

If you read this far, tweet to the author to show them you care. Tweet a Thanks

More Posts

Define the missing method. use "this" to distinguish the local member from the parameter name. James - Jun 1
The solution to the error the given key was not present in the dictionary. zhteja - Aug 9
The function was not declared in this scope c++ AnkurRanpariyav - Aug 7
External Table is Not in the Expected Format zhteja - Aug 5
Check if the vector contains the given element or not in C++ AnkurRanpariyav - Aug 3