8

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

Community
  • 1
  • 1
Phill Ash
  • 361
  • 1
  • 2
  • 7
  • Just copy paste your sdk directory into new folder and dont put space in directory name – Pankaj Jun 02 '15 at 08:01
  • Hi, my ANDROID_HOME variable does not have any spaces in it. /Users/Phill/Library/Android/sdk This is as per the android studio value. – Phill Ash Jun 03 '15 at 07:26
  • Furthermore I have been attempting to add --stacktrace options to be able to view the build output problem in eclipse however this doesn't seem to have worked either. I added --stacktrace --debug --info as per these instructions: http://stackoverflow.com/questions/21674091/how-to-add-stacktrace-or-debug-option-when-building-android-studio-project – Phill Ash Jun 04 '15 at 07:44
  • I think this must be a problem within eclipse itself because I have installed gradle (setup the GRADLE_HOME and PATH) rather than using the eclipse plugin and it builds fine. So it must be something to do with the way eclipse is building the package... – Phill Ash Jun 07 '15 at 12:05

2 Answers2

16

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?

Community
  • 1
  • 1
Phill Ash
  • 361
  • 1
  • 2
  • 7
  • If you are using AndroidStudio 2 the `local.properties` file is changed by the IDE when you add it to a new project. You can modify the directory in AndroidStudio 2 Preferences. – wdev May 30 '16 at 15:05
1

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.

Matt
  • 4,462
  • 5
  • 25
  • 35
Tanel
  • 1,080
  • 9
  • 16