Gradle: SDK location not found, the problem and solution

02 Jul

In a recent project, I created a Gradle project in windows, but when I load the project in Ubuntu and Mac OSX, an error “SDK location not found. Define location with sdk.dir in the file or with an ANDROID_HOME environment variable”


I then followed the instruction, and in the ~/.bashrc file, I added the environment variable ANDROID_HOME


And then I sourced this file in the terminal:

source ~/.bashrc

When rebuilding the gradle model, the same problem persists!

To troubleshoot this, I then followed the instruction as shown in the first snapshot:

  • Create a new file called in the root folder of the gradle project

image   image
  Before adding                     After adding

  • Edit the newly created file, add the single line as following:



where “/home/user/Android/adt/sdk” is the path where installed the Android SDK.

  • Rebuild the model, now it works!

This approach is also applicable to Mac OSX!



Happy coding!


Posted by on July 2, 2014 in General, Linux, Mac, Programming, Windows


Tags: , , , , , , , , , , , , ,

8 responses to “Gradle: SDK location not found, the problem and solution

  1. LBC

    February 16, 2015 at 6:37 am

    I spent hours trying to resolve this very issue. Well written, easy to understand. Thank you very much for sharing and getting me out of Android jail… !

  2. Wilamis Micael

    March 2, 2015 at 9:40 am

    Cara me ajudou muitoooo!!!! Te agradeçooooooooo muitooooooo thanks

  3. tg_dev

    August 5, 2015 at 7:48 am

    Fine, Fine Fine!!! Thank you very much.

  4. LAM

    July 20, 2016 at 10:14 pm

    Thank you very much !

  5. Andrew Shamrao

    September 6, 2016 at 4:33 am


    Your instructions are very clean and easy to follow. Unfortunately, I’m a bit new to all this and can’t figure out where to look for the “root folder of the gradle project.” Go I look in “Documents an Settings/My folder/.gradle”?

  6. Andrew Shamrao

    September 6, 2016 at 2:47 pm

    should the “” file be a text file, or some other filetype? It’s not working for me on my windows machine. Thanks!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: