Home » Android » android – SDK location not found. ANDROID_HOME – building a gradle project in eclipse on a MAC

android – SDK location not found. ANDROID_HOME – building a gradle project in eclipse on a MAC

Posted by: admin June 15, 2020 Leave a comment

Questions:

I’m in the process of running through a tutorial on getting Libgdx working with eclipse on my MAC.

I am currently building one of the example projects using gradle in eclipse so I can run through the tutorials and learn a bit more. When I import and build the example code project (I’m using a MAC) I get the below error message:

“SDK location not found. Define a location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable”.

In an attempt to resolve this problem I have attempted and checked the following:

1) Installed the latest version of the JDK and setup JAVA_HOME – confirmed existence by echoing the variable from a terminal.

2) Installed the latest and various other versions of the android SDK and plugins and setup ANDROID_HOME. – Confirmed by checking the Android Studio SDK location and echoing $ANDROID_HOME

3) I also found this thread and the suggested solution was to update local.properties with sdk.dir which I have also tried and I still get the same error:

Gradle, Android and the ANDROID_HOME SDK location

4) I have setup the eclipse android preferences to make sure it is looking at ANDROID_HOME and it can see the various SDK folders.

I have also made a few attempts to add the –stacktrace options via android studio however that hasn’t seemed to produce output in eclipse.

I’m going to try building the project via the commandline outside eclipse now and see if that works.. Has anyone come across this issue before?

Phill

How to&Answers:

I finally fixed this after 10 hours of racking my brains and trying every solution under the sun.

The solution was to set the sdk.dir in the local.properties file as the error suggested. Where I was going wrong was the location of the local.properties file.

This must be in the projects root folder (i.e where settings.gradle, gradlew and gradlew.bat are) as the below thread suggests!

Where does local.properties go for android project?

Answer:

I had the same error and couldn’t find an answer to fix my problem. It was quite simple actually. Some replies say to place the local.properties file in the project root. Your project root isn’t in /../projectlocation, but in /../projectlocation/android, if you’re building for android. After moving my local.properties from /projectlocation to /projectlocation/android, it works.