'SDK Location not found' in Android Studio despite having the environment variable set correctly

萝らか妹 提交于 2020-02-04 05:46:06

问题


I am a little confused why I am getting this message when the ANDROID_HOME environment variable is actually set.

It is also set in project defaults:

I am probably missing something trivial here, but not sure what. Thanks


回答1:


Check your local.properties file

If sdk.dir="Your sdk path" is not available in the file. Please add it and try.




回答2:


Faced the same issue with Intellij IDEA 2017.2 on MacOS Sierra. I have two projects with different Build targets (26 and 25). Both projects were created on Win and committed to Git.

The First cloned project was with Build target 26. All needed SDK platforms and tools were downloaded with SDK Manager. The project compiled and built without any errors. I didn't set up ANDROID_HOME variable or create local.properties file. I just set up the "Android SDK home path" within IDEA.

The Second cloned project was with Build target 25. I downloaded all needed SDK platforms and tools for this target. Then I configured new SDK for the Android API 25 platform. On Build APK got the error "SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable". I tried many solutions (created ANDROID_HOME, re-installed SDK, changed settings many times) except local.properties creation - nothing works for me. As I use the same project on different platforms the creation of the local.properties file is not a good choice.

Today I made a strange thing. I clicked the Edit link near the Android SDK Location field in the SDK Manager. Then Next -> Next -> Finish.

And my issue gone.




回答3:


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.




回答4:


You should define sdk path in your local.properties file and also in the Android SDK home path.

local.properties file is not available in your project. Please add it Gradle scripts and give the sdk path to sdk.dir

It will resolve your issue.




回答5:


Please check correct sdk path in your local.properties file and also in the Android SDK home path.

If still not successful, You have to just copy your local.properties file to the folder where project is stored and it will work. But remember, it must be placed in the root folder where the project is stored.



来源:https://stackoverflow.com/questions/40298653/sdk-location-not-found-in-android-studio-despite-having-the-environment-variab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!