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

I recently tried to import sample Android games I downloaded from Google’s developer website. After importing them into Android Studio, I’m getting the following error:

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

  • Set constant value with gradle
  • Optimal WebView Settings for HTML5 Support?
  • Sign in with Facebook if account already linked with google during initial signup in Firebase Android
  • How to detect touch events in Android
  • why we can call getActivity() in onCreateView which run before onActivityCreated?
  • How to completely disable soft keyboard for all input in Android webview
  • What is this? I want to run the sample programs from Android Studio.

    Related posts:

    Extract substring from a string
    Android library not pulling its resources through to other projects
    Volley - download directly to file (no in memory byte array)
    How can I stop the LogCat output from scrolling automatically in Eclipse?
    String comparison - Android
    MarkerClick works but InfoWindowClick does not open ViewModel
  • Migrating SVN to Android Studio
  • ContentProvider without SQL
  • How to make my own custom dialer in an Android phone
  • Can we post image on twitter using twitter API in Android?
  • Get the string value from List<String> through loop for display
  • What is the difference between Dalvik VM and ART Runtime?
  • 12 Solutions collect form web for “SDK location not found. Define location with sdk.dir in the file or with an ANDROID_HOME environment variable”

    The project might be missing a settings.gradle file. Make sure that file exists from the project you are importing. If not add the settings.gradle file with the following :

    include ':app'

    Save the file and put it at the top level folder in your project.

    I know this answer is late, but I hope it helps others.

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

    Check out in your file


    properly write this formate, and also check / slas using for path

    Please follow bellow points it work’s for me:

    1. Go to your Project -> Android
    2. Create a file
    3. Open the file
    4. paste your Android SDK path like below

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

    Replace USERNAME with your user name

    If you are trying to run Google android sample code, try to import the entire repository instead of an individual sample.

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

    • Import calendar-android-sample project
      • Select “Import Project…” or File > Import Project…
      • Select [someDirectory]/google-api-java-client-samples/build.gradle and
        click OK.

        • Note: it will not work if you try to import [someDirectory]/google-api-java-client-samples/calendar-android-sample/build.gradle
      • Select “Use local gradle distribution” with “Gradle home” of [someDirectory]/gradle-2.2.1 and click OK.

    In Linux:
    If you have already downloaded the android SDK but its not being found. The problem might be that the file needs to be inside the same directory as gradle stuff for gradle to find it when building and running adb. For my react-native project using gradle I needed to put the file to Myprojectname/android/ folder.

    As I had unzipped the SDK to Downloads so I just use that path in the file with a row like this:

    There is not a single reason for this error.

    1>settings.gradle may be missing or the content in it may be wrong.
    2> may be missing or the sdk path may be wrongly written.

    Just Remove .idea folder and import the project again. It’s worked for me.

    Found working solution for me. Without adding and set up ANDROID_HOME variable. Seems like a bug in Android Studio and Intellij IDEA.
    You just need to ask IDE to “reset” path to Android SDK.
    'SDK Location not found' in Android Studio despite having the environment variable set correctly

    1. In Module settings, whether, SDK location is proper.
    2. If Yes, check for file (Not the one placed inside app module, but the one placed outside the app module, at parent level). If not present add it with below lines inside it.


    I resolved this issue by creating ANDROID_HOME environment variable as follows in windows.


    Restart Android Studio it should build project!

    You should download The Android SDK.

    Use this link to download it.

    Then you should define its location to Android Studio. Follow the steps:

    1. File->project Structure into Project Structure
    2. Left > SDK Location
    3. SDK location select Android SDK location (old version use Press +, add another sdk)

    Good luck.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.