在android studio中找不到SDK位置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25596284/
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
SDK Location not found in android studio
提问by BST Kaal
I have just imported my eclipse project in android studio. it keeps my saying that
我刚刚在 android studio 中导入了我的 eclipse 项目。我一直这么说
Error:SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
I have seen some tutorials of editing local.properties files but it didnt work. here is my project.properties file:
我看过一些编辑 local.properties 文件的教程,但是没有用。这是我的 project.properties 文件:
sdk.dir=E:\Mod Eclipse\adt-bundle-windows-x86_64-20130219\sdk
Actual directory of my folder is :
我的文件夹的实际目录是:
E:\Mod Eclipse\adt-bundle-windows-x86_64-20130219\sdk
E:\Mod Eclipse\adt-bundle-windows-x86_64-20130219\sdk
采纳答案by Onur A.
You should also change it on Project Structure.
您还应该在项目结构上更改它。
Close the current project and you'll see pop up with dialog which will then proceed to Configure option.
Configure -> Project Defaults -> Project Structure -> SDKs on left column -> Android SDK Home Path -> give the exact path as you did on local.properties and select Valid Target.
关闭当前项目,您将看到弹出对话框,然后继续配置选项。
Configure -> Project Defaults -> Project Structure -> SDKs on left column -> Android SDK Home Path -> 给出你在 local.properties 上所做的确切路径,然后选择 Valid Target。
There you go.
你去吧。
回答by Daniel Wilson
A quick note about this if trying to run a Facebook sample and this error pops up, make sure you select the build.gradle file in the root of Facebook sdk, for all the samples when 'opening an existing project'. I got this error when I tried to open the gradle for just the Scrumptious sample from the 3.22 SDK
如果尝试运行 Facebook 示例并弹出此错误,请对此进行快速说明,请确保在“打开现有项目”时为所有示例选择 Facebook sdk 根目录中的 build.gradle 文件。当我尝试为 3.22 SDK 中的 Scrumptious 示例打开 gradle 时出现此错误
回答by DeltaCap019
If you are sure that you have assigned correct SDKpath in project settings, and you can see it in local.propertiesas well, but still getting this error then there are chances that you are missing something in you project.
如果您确定在项目设置中分配了正确的SDK路径,并且您也可以在local.properties 中看到它,但仍然收到此错误,那么您可能在项目中遗漏了某些内容。
I was getting the same error after looking in to my project I found settings.gradlewas missing.
and then add following script to your apps build.gradle
You will not face this error any more. It worked for me may be gradle set upwas the blocking issue
在查看我的项目后发现settings.gradle丢失时,我遇到了同样的错误。
然后将以下脚本添加到您的应用程序build.gradle
您将不会再遇到此错误。它对我有用,可能是gradle 设置是阻塞问题
回答by Uriel Frankel
My problem was:
我的问题是:
- I cloned a project from github
- I clicked open existing Android Studio project
- I chose the path of the inner sample app instead of the containing folder.
- 我从github克隆了一个项目
- 我点击了打开现有的 Android Studio 项目
- 我选择了内部示例应用程序的路径而不是包含文件夹。
So what you should do is:
所以你应该做的是:
- close the project.
- click open existing Android Studio project
- select the parent folderinstead of the sample app.
- 关闭项目。
- 单击打开现有的 Android Studio 项目
- 选择父文件夹而不是示例应用程序。
回答by Andriy
The simplest solution sometimes is just do the File -> Invalidate Cache / Restart.
有时最简单的解决方案就是执行File -> Invalidate Cache / Restart。
If it does not help then go for the more complicated stuff, as suggested in other answers
如果它没有帮助,那么按照其他答案中的建议去做更复杂的事情
回答by Idan Magled
In my case, it was a fresh install with checkout from github.
就我而言,这是一个全新安装,从 github 结帐。
- Just close the checkout window.
- Create a new project (not from git, just a fresh one).
- exit the project.
- checkout whatever you like
- 只需关闭结帐窗口。
- 创建一个新项目(不是来自 git,只是一个新项目)。
- 退出项目。
- 结帐任何你喜欢的
Its just the fastest way that I found.
它只是我找到的最快的方法。
回答by Kris Roofe
You can add a local.properties with to set the sdk.dir like sdk.dir=/Users/roofe/Library/Android/sdk
.
您可以添加一个 local.properties 来设置 sdk.dir sdk.dir=/Users/roofe/Library/Android/sdk
。
But please note below, which is very important,
但请注意以下,这很重要,
add the local.properties to the uppermostpath of the project. Here the uppermosthave some difference with root pathof a project.
将 local.properties 添加到项目的最上层路径。这里最上面的与项目的根路径有一些区别。
For example in the below project, I just use the ijkplayer-example, but this module also used other module with different cpu architecture.
例如在下面的项目中,我只使用了 ijkplayer-example,但是这个模块也使用了其他不同 cpu 架构的模块。
If I only add local.properties to ijkplayer-example will not work. Here will get sdk location issue for other module.
如果我只将 local.properties 添加到 ijkplayer-example 将不起作用。这里将得到其他模块的 sdk 位置问题。
While I can add the local.properties to the ijkplayer directory, then when I try to open the ijkplayer-example project, there will auto create a local.properties for ijkplayer-example, and everything works well.
虽然我可以将 local.properties 添加到 ijkplayer 目录,但是当我尝试打开 ijkplayer-example 项目时,会自动为 ijkplayer-example 创建一个 local.properties,一切正常。
回答by O'Kamiye
So I had the same issue, and none of the answers given previously helped me. What I did was check for new API updates (in my case, I updated to API level 23) and the problem was fixed.
所以我遇到了同样的问题,之前给出的答案都没有帮助我。我所做的是检查新的 API 更新(在我的情况下,我更新到 API 级别 23)并解决了问题。