git 未找到 SDK 位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32177349/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:18:20  来源:igfitidea点击:

SDK Location not found

androidgit

提问by Fustigador

I created recently a new local repo and pulled some code to it, from our remote repository.

我最近创建了一个新的本地存储库,并从我们的远程存储库中提取了一些代码。

When i open the project, I receive a message in console:

当我打开项目时,我在控制台中收到一条消息:

Gradle sync failed: SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
     Consult IDE log for more details

I followed the instructions hereto set the environment variable (Im in a Mac) and checked my local.properties:

我按照此处的说明设置环境变量(我在 Mac 中)并检查了我的 local.properties:

sdk.dir=/Users/admin/Library/Android/sdk

So, both things are settled up, and I am still getting this error. Ive searched, but no solution worked for me.

所以,这两件事都解决了,我仍然收到这个错误。我已经搜索过,但没有解决方案对我有用。

Any help? Thank you.

有什么帮助吗?谢谢你。

EDIT:

编辑:

This only happens with one project. The rest of the projects works perfectly.

这只发生在一个项目中。其余项目完美运行。

回答by Gil Moshayof

In Android Studio:

在 Android Studio 中:

  1. Open your project navigator
  2. Pick the root item, right click --> Open Module Settings.
  3. In the Android SDK location field, make sure the correct path is selected (up to the sdk folder). See example below:
  1. 打开您的项目导航器
  2. 选择根项目,右键单击--> 打开模块设置。
  3. 在 Android SDK 位置字段中,确保选择了正确的路径(直到 sdk 文件夹)。请参阅下面的示例:

enter image description here

在此处输入图片说明

回答by Philip Rego

I had the same issue and tried the above comments. Later on the error changed to

我遇到了同样的问题并尝试了上述评论。后来错误改为

"Gradle sync failed: failed to find Build Tools revision 23.0.1 Consult IDE log for more details (Help | Show Log)"

“Gradle 同步失败:无法找到构建工具修订版 23.0.1,请查阅 IDE 日志以获取更多详细信息(帮助 | 显示日志)”

It installed the revision then the gradle build completed. So try updating your SDK.

它安装了修订版,然后 gradle 构建完成。因此,请尝试更新您的 SDK。

回答by Buhiire Keneth

On Linux(Ubuntu 16.04) you can set the ANDROID_HOME environment variable by editing the ~/.bashrcfile, by running nano ~/.bashrcthen adding the environment variable which points to the path of your Android Sdk in my case which is '/home/kbuhiire/Android/Sdk'thus the environment variable looks something like this. export ANDROID_HOME='/home/kbuhiire/Android/Sdk'and after saving the file run source ~/.bashrc.

在 Linux(Ubuntu 16.04)上,您可以通过编辑~/.bashrc文件来设置 ANDROID_HOME 环境变量,通过运行nano ~/.bashrc然后添加指向 Android Sdk 路径的环境变量,在我的情况下,'/home/kbuhiire/Android/Sdk'环境变量看起来像这样。 export ANDROID_HOME='/home/kbuhiire/Android/Sdk'并在保存文件后运行source ~/.bashrc.