Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDK Location not found Android Studio + Gradle

I have seen this same thing posted quite a few times, but whenever I try to import my project to my new work laptop I keep getting this error.

I have pulled the project from git (which his btw running fine on my old laptop).

Then I went to the sdk manager, downloaded all the tools, and all the SDK's available. In the welcome screen, I went to Configure -> project Defaults -> Project structure. Android SDK Tab says the path for projects without local.properties will be /Applications/Android Studio.app/sdk This is correct. Under SDKs I have all the available SDK's visible. Project SDK is set to API 18

Yet still I get this error when trying to build my project. Can anyone tell me where I havent looked yet?

I am running gradle 1.7 when trying to build which is downloaded from services.gradle.org

like image 521
Mathijs Segers Avatar asked Oct 09 '13 12:10

Mathijs Segers


People also ask

How do I fix Android SDK not found?

Quick fix: Go to the Tools –> SDK manager –> SDK tools. Deselect Hide obsolete packages option on the right bottom and further install Android SDK Tools(obsolete). A new folder named Tools is now generated in the SDK directory. (C:\Users\..

Where is SDK location in Android Studio?

by default, the "Android Studio IDE" will be installed in " C:\Program Files\Android\Android Studio ", and the "Android SDK" in " c:\Users\username\AppData\Local\Android\Sdk ".

Can not find Android SDK folder?

If you have downloaded the AS + SDK bundle: Note #2: you will never find the SDK in the Android Studio directory unless you have explicitly put it in there. The reason is that those directories might be deleted after installing a newer version of Android Studio and you would have to re-install the SDK as well.

Why Android SDK is not installed?

Open the Tools\Options\Xamarin\Android Settings and set a new Android SDK Location (the folder should not exists). automatically the IDE detect that the Android SDK is not installed and it will propose you to install all the required components. after that open the Tools\Android\Android SDK Manager...


1 Answers

I had very similar situation (had a project on another machine and cloned it to my laptop and saw the same issue) and I looked in it.

Error message was coming from Sdk.groovy of Android gradle plugin: https://android.googlesource.com/platform/tools/build/+/master/gradle/src/main/groovy/com/android/build/gradle/internal/Sdk.groovy

By looking at code, its findLocation needs to set androidSdkDir variable and there are only three ways to do it:

  • create local.properties file and have either sdk.dir or android.dir line.
  • have ANDROID_HOME environment variable defined.
  • System.getProperty("android.home") - I'm not sure how it works, but it seems like a Java thing.

While your Android Studio knows that the SDK is at that place, I doubt that Android Studio is passing that information to gradle and thus we're seeing that error.

I created local.properties file at the project root and put the following line and it compiled the code successfully.

sdk.dir = /Applications/Android Studio.app/sdk/

like image 150
Gaku Ueda Avatar answered Oct 12 '22 20:10

Gaku Ueda