SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
问题描述:
已经安装了android-sdk 和gradle环境,并配置了环境变量,如下所示:
android环境
root@wangju-HP-348-G4:/home/wangju/Desktop/5i5j_android/AppFrameWork# adb version
Android Debug Bridge version 1.0.41
Version 29.0.5-5949299
Installed as /usr/local/android-home/android-sdk-linux/platform-tools/adb
gradle环境:
root@wangju-HP-348-G4:/home/wangju/Desktop/5i5j_android/AppFrameWork# gradle -version
------------------------------------------------------------
Gradle 4.6
------------------------------------------------------------
Build time: 2018-02-28 13:36:36 UTC
Revision: 8fa6ce7945b640e6168488e4417f9bb96e4ab46c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_211 (Oracle Corporation 25.211-b12)
OS: Linux 4.15.0-72-generic amd64
在android项目的app目录下执行gradle clean/tasks命令时会报如下错误:
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
> Must apply 'com.android.application' first!
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
解决办法:
根据错误提示
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
翻译过来的意思就是:没有找到sdk,可以在local.properties这个文件中定义android_home,即指明android sdk的所在位置
在app目录下新建local.properties文件,文件内容如下所示:
/usr/local/android-home/android-sdk-linux 是我android sdk的安装目录
sdk.dir=/usr/local/android-home/android-sdk-linux
配置好后,再用gradle clean即可
参考文档:
https://blog.csdn.net/cocos2dx_3_0/article/details/51235732