SDK位置没有发现Android的工作室+摇篮 [英] SDK Location not found Android Studio + Gradle

查看:143
本文介绍了SDK位置没有发现Android的工作室+摇篮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了同样的事情贴了好几次,但每当我尝试我的项目导入到我的新工作,笔记本电脑,我不断收到此错误。

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).

然后我去了SDK管理器,下载所有的工具,所有的SDK的使用。 在欢迎屏幕上,我去配置 - >项目的默认设置 - >项目结构。 Android的SDK标签表示不local.properties为项目的路径是/应用/ Android的Studio.app / SDK 这是对的。 在软件开发工具包我把所有可用的SDK的可见。 项目SDK设置为API 18

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?

我想建立是从services.gradle.org

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

推荐答案

我有非常类似的情况(有一个项目在另一台机器,并克隆到我的笔记本电脑,看到了同样的问题),我看着它。

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.

错误消息是从Android的摇篮插件 Sdk.groovy 未来: <一href="https://android.googlesource.com/platform/tools/build/+/master/gradle/src/main/groovy/com/android/build/gradle/internal/Sdk.groovy">https://android.googlesource.com/platform/tools/build/+/master/gradle/src/main/groovy/com/android/build/gradle/internal/Sdk.groovy

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

通过查看code,其 findLocation 需要设置 androidSdkDir 变量,只有三种方式要做到这一点:

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

  • 创建 local.properties 文件,要么 sdk.dir android.dir 行。
  • ANDROID_HOME 环境变量定义。
  • System.getProperty(android.home) - 我不知道它是如何工作的,但它似乎是一个Java的事情
  • 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.

在你的Andr​​oid工作室知道该SDK是在那个地方,我怀疑Android的工作室正在通过这些信息来摇篮,因此,我们所看到的错误。

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.

我在 local.properties 文件在项目的根,把下面的行,并编制了code成功。

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

sdk.dir = /应用/ Android的Studio.app / SDK /

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

这篇关于SDK位置没有发现Android的工作室+摇篮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆