SDK Location not found Android Studio + Gradle

Posted Android 从零单排

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SDK Location not found Android Studio + Gradle相关的知识,希望对你有一定的参考价值。

extends: http://stackoverflow.com/questions/19272127/sdk-location-not-found-android-studio-gradle

 
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/ 

以上是关于SDK Location not found Android Studio + Gradle的主要内容,如果未能解决你的问题,请参考以下文章

SDK location not found. Define location with sdk.dir in the local.properties

A problem occurred configuring project ‘:app‘.> SDK location not found. Define location with sdk.di(

高德地图测两点距离android比较精确的

mac android studio 出现 Error: SDK location not found. Define location with sdk.dir in the local.prope

SDK Location not found Android Studio + Gradle

SDK location not found, define location with sdk.dir in the local.properties