Gradle: SDK location not found, 问题与解决

来源:互联网 发布:ubuntu exe安装包 编辑:程序博客网 时间:2024/06/08 07:38

原文链接

https://xinyustudio.wordpress.com/2014/07/02/gradle-sdk-location-not-found-the-problem-and-solution/


我是在cocos3.10新建项目无法用android studio打开时遇到的。

原文中写的非常清楚和详细。非常感谢原作者!


In a recent project, I created a Gradle project in windows, but when I load the project in Ubuntu and Mac OSX, an error “SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable”

问题图片

image

I then followed the instruction, and in the ~/.bashrc file, I added the environment variable ANDROID_HOME

我然后修改了 ~/.bashrc file来添加环境变量

(我是在终端中输入  open .bash_profile  后在里面加入了  export ANDROID_HOME=/user...你的sdk地址

image

And then I sourced this file in the terminal:

source ~/.bashrc

When rebuilding the gradle model, the same problem persists!

To troubleshoot this, I then followed the instruction as shown in the first snapshot:

  • Create a new file called local.properties in the root folder of the gradle project

image   image
  Before adding local.properties                     After adding local.properties 

  • Edit the newly created local.properties file, add the single line as following:
  • 在新项目中新建一个  local.properties 文件,在里面添加一行代码

sdk.dir=/home/user/Android/adt/sdk

image

where “/home/user/Android/adt/sdk” is the path where installed the Android SDK.

/home/user/Android/adt/sdk是你的sdk路径

  • Rebuild the model, now it works!

This approach is also applicable to Mac OSX!

image

image

Happy coding!

大功告成
0 0
原创粉丝点击