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

androidgradle

I'm trying to run this sample project using GraphQL with the Apollo Android client: https://github.com/apollographql/apollo-android/tree/master/apollo-sample

I'm new to Android studio, here's what I did so far:

  1. Installed Android Studio on my machine (mac)
  2. Clone full Apollo Android repo
  3. Started Android studio and opened the apollo-sample directory from the cloned repo as an Android project

I am now getting this build error:

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

It's the same issue that's described in this SO question, however none of the solutions of the suggested answer worked for me:

I do have a local.properties file in the root directory of the project that has the sdk.dir set:

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

I don't actually know where this entry is coming from, but it's definitely there. I'm assuming it points to the right location, the contents of that path are the following directories:

build-tools
emulator
extras
patcher
platform-tools
platforms
sources
tools

I also tried to set the ANDROID_HOME env var as suggested in the accepted answer but this didn't work either:

Best Answer

Try opening SDK manager in Android studio and see if the SDKlocation is set correctly.