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 local.properties file or with an ANDROID_HOME environment variable”

image
I then followed the instruction, and in the ~/.bashrc file, I added the environment variable ANDROID_HOME
image
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 local.properties in the root folder of the gradle project
image   image
  Before adding local.properties                     After adding local.properties
  • Edit the newly created local.properties file, add the single line as following:
sdk.dir=/home/user/Android/adt/sdk
image

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!
image
image
Happy coding!

Post a Comment

 
Top