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.
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.
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.
Check your local.properties file
If sdk.dir="Your sdk path" is not available in the file. Please add it and try.
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.
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.
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.
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.