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
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.
Check your local.properties file
If sdk.dir="Your sdk path" is not available in the file. Please add it and try.
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.
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.
We decided to use GitHub as our version control. I know the Gradle build scripts use certain paths, such as the Android SDK path in the local.properties file.
Since this path will differ between the five of us, I think the projects will fail to build on my teammates' machines when they pull changes from GitHub. Is this correct?
If so, can we all make an environment variable called something like ANDROID_SDK and use that for the sdk.dir in the local.properties? Would the project properly build on all of our machines if we used the environment variable? Are there any other places where we may need to set
a similar environment variable? Will this work? If so, how do we do this?
I am not sure if this is the best way to go about setting up a team project for Android. I'm looking for suggestions on a best practice for this.
Is this correct?
No, because IMHO local.properties should not be in your Git repo. The standard Android Studio .gitignore file (created when you create the project) has local.properties, meaning that local.properties would not be committed to your repo.
As Doug Stevenson points out in a comment, local.properties is generated when you import a project. It will be driven by Android Studio settings.
can we all make an environment variable called something like ANDROID_SDK and use that for the sdk.dir in the local.properties?
Not for use with Android Studio, at least the last I tried it. For command-line Gradle builds, that works fine, but Android Studio does not pass the environment to its forked Gradle process.
I am using Android Studio for a project on SVN (usually on Windows PCs).
Lately I want to run this on a Mac, it keep giving the below error:
Error:The SDK directory '/Users/AhmadMusa/Desktop/[PROJECT PATH]/D:\Android\sdk' does not exist.
Please fix the 'sdk.dir' property in the local.properties file.
I already put the SDK on local.properties file as:
sdk.dir=/Users/AhmadMusa/Library/Android/sdk
I don't know why it keep adding the (D:\Android\sdk) automatically, this is my Windows PC SDK directory, but why it is here now! nothing on code mention any D:\Android\sdk.
Right click your project and select 'Open Module Settings' under SDK Location put your location for your SDK.
paste in /Users/AhmadMusa/Library/Android/sdk
Clean and rebuild your project
Update
Try to delete your local.properties file and create a new one, but do not check it into version control.
Right click top level of project and Create new file 'local.properties'
then add: sdk.dir=/Users/AhmadMusa/Library/Android/sdk
Clean and build
I finally find this file on the disk.The 'local.properties' file in The Android studio is not which you modify.see the picture,so you can modify this line 'sdk.dir' to your dir of sdk.Remember not in the android studio.
This is a problem when you open the project incorrectly. open the project do not import the project
Create or edit file local.properties under android directory
For window path should be like this
sdk.dir = C\:\\Users\\user name\\AppData\\Local\\Android\\sdk
For linux system path should be like this
sdk.dir = /home/user name/Android/Sdk/
Open your project folder
open local.properties in notepad++
change sdk.dir to C:\Users\xxxx\AppData\Local\Android\Sdk
save
After edit, resync again android studio.
I solve this problem, the reason is: You downloaded other's projects. His local.properties file content is his SDK path. You must replace SDK path with your local SDK path, then rebuild the project.
From Android Studio 1.0.1
Go to
File -> project Structure into Project Structure
Left -> SDK Location
SDK location select Android SDK location (old version use Press +, add another sdk)
Change the sdk path to /Users/AhmadMusa/Library/Android/sdk
I solved this issue in Windows using this format for the full path:
sdk.dir=C:/Users/xxxx/AppData/Local/Android/Sdk
I think you should go to:
File ->Project Structure->SDK Location->
there select your sdk location.
Just open your local.property file
if your project is used in mac before, so the sdk path will be something like
sdk.dir=/Users/siddharthyadav/Library/Android/
Now if you are trying to use that in windows so just edit and put your sdk location:
Example:
sdk.dir=D:\software\android-sdk\android-sdk
Just clean and build. See it works!!!
Just close your project and re-open it again.
Than SDK message appears click ok.
Today upgraded to Android 3.3, which broke everything for me.
This one was related to importing the project, not opening it.
Solution which worked for me, was to import the project. During the import it detects that the SDK directory is missing and proposes to open it from a location which actually exists. It worked in my case but your case might be different.
Many other changes still needed to be done to make old projects work. What a pain any update is. I wonder why don't they do a thorough QA first before releasing these updates. It has become an industry norm to release problem filled software, probably thinking that users will figure out solutions via Stackoverflow.
I had the same problem. Just open the project main folder. and then close and reopen the project sub folder app.
In my case, my project is located inside another Android project.
Therefore, I opened the local.properties of the parent project and fix the sdk.dir's path there.
Select SDK Location: File->Project Structure->SDK Location->
Close Android Studio.
Remove .gradle and .idea folders, local.properties, all .iml files in the project: <module_name>/<module_name>.iml
Open Android Studio and select Open an existing Android Studio project
Select path to your project
This way must to help.
Checkout your SDK manager in Android studio, if you have partially installed sdk. Install SDK completely and try running your code.
I had a ; in the environment variable name, put it out and it will works !
refollow the steps after the verification of the ANDROID_HOME
react init
=> run you emulator
=> run-android
sdk.dir didn't work for me because I had ANDROID_HOME environment variable with wrong path. So, solution is just to update ANDROID_HOME or remove it to use local.properties.
Android Studio restart is required after the change.
I faced the same problem - it was solved by only the following step.
I deleted all created .idea and .gradle folders.
It is the path problem I faced while loading source in SDK, I think.
If you have set the ANDROID_HOME variable, just remove or comment that line in local.properties file. It is the solution for me
in latest Android Sudio 3.2.1
1- you will see two files with the name 'local.properties'
2- one will be inside folder named 'app' ( app level folder ), Only if you have not yet been able to sync your project. if you cant see it in the folder strucrure in Android studio then physically find this folder in Finder . (right click and reveal in finder in case you use a MAC machine). Make changes here.
3- and other will be inside 'gradle script'
make sure you have same path there . Also make changes here (if you can see this file)
Basically find this file at its physical location in the project folder (physical location ) and make changes
eg. : sdk.dir=/Users/Rakesh/Library/Android/sdk
in both the files .
My solution: open app on Android studio.
Check sdk and clean App, after rebuild I had fixed this problem by following suggestions of Android Studio.
finally run app with react-native run-android/ios
This might due to merge conflict same as mine, try to change local.properties for me it was wrong location for android sdk as it was override from other machine
ndk.dir=/Users/???/Library/Android/sdk/ndk-bundle
sdk.dir=/Users/???/Library/Android/sdk
then rebuild
If your project is a subproject, the problem may lie on the parent local.properties file. I may suggest you to go up in the project hierarchy to the root file and execute the following command:
$ find . -type f -exec grep -l sdk.dir {} \;
That would work on OSX and Linux, if you are in Windows you may need to install Cygnus tools or something akin (I don't use Windows, so I cannot be more precise). If the path is wrongly set in some file, you'll find it with that command, then it is just a matter of opening the file with a text editor and replacing the wrong path with the right one.
My scenario is I open the project, and the local.properies shows my sdk.dir.
But it keeps telling me it need the sdk from the previous other user's dir.
So I close the project and re-import the project, and everything works fine.
Choose one of the options-
OPTION A
Delete the 'local.properties' file in 'Gradle Script'
Create new 'local.properties' file there
Paste this into your new 'local.properties' file
sdk.dir=/Users/uttam/Library/Android/sdk
OPTION B
copy the 'local.properties' file from your any old project.
paste this in your new project, you will be asked confirmation, choose 'replace'
HAPPY CODING :)
Fix the root cause. If you check the other answers they suggest to find the SDK location property and fix that. Assume you have that correctly set, otherwise you won't have any SDK components downloaded on your system. Then something in your environment is telling AndroidStudio where to find the sdk.dir. Since AndroidStudio will create this local.properties file for you, it is likely first checking the stored property of "Android SDK" System settings for this location. It should use this value in the local.properties. If you find that it still gets the wrong value, the root cause is that AndroidStudio fills the sdk.dir property from ANDROID_HOME, found in the host system environment. Fix this and it fixes the problem. You will need to (1) correctly set ANDROID_HOME or unset the variable for ANDROID_HOME (2) remove the existing local.properties (3) restart your AndroidStudio.
You need to change sdk.dir='...' in local.properties file as per your sdk location.
For checking sdk location, open File -> Project Structure -> SDK Location. If sdk location is also not correct there, you can also update it.
Go to your project_folder/platform/android/
Open local.properties in your text editor
Change URL with your SDK URL
sdk.dir = C:\Users/Pcesolutions/AppData/Local/Android/Sdk
Now run your command in windows
Its worked for me. I think, it work's also in your PC.
I'm in the process of running through a tutorial on getting Libgdx working with eclipse on my MAC.
I am currently building one of the example projects using gradle in eclipse so I can run through the tutorials and learn a bit more. When I import and build the example code project (I'm using a MAC) I get the below error message:
"SDK location not found. Define a location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable".
In an attempt to resolve this problem I have attempted and checked the following:
1) Installed the latest version of the JDK and setup JAVA_HOME - confirmed existence by echoing the variable from a terminal.
2) Installed the latest and various other versions of the android SDK and plugins and setup ANDROID_HOME. - Confirmed by checking the Android Studio SDK location and echoing $ANDROID_HOME
3) I also found this thread and the suggested solution was to update local.properties with sdk.dir which I have also tried and I still get the same error:
Gradle, Android and the ANDROID_HOME SDK location
4) I have setup the eclipse android preferences to make sure it is looking at ANDROID_HOME and it can see the various SDK folders.
I have also made a few attempts to add the --stacktrace options via android studio however that hasn't seemed to produce output in eclipse.
I'm going to try building the project via the commandline outside eclipse now and see if that works.. Has anyone come across this issue before?
Phill
I finally fixed this after 10 hours of racking my brains and trying every solution under the sun.
The solution was to set the sdk.dir in the local.properties file as the error suggested. Where I was going wrong was the location of the local.properties file.
This must be in the projects root folder (i.e where settings.gradle, gradlew and gradlew.bat are) as the below thread suggests!
Where does local.properties go for android project?
I had the same error and couldn't find an answer to fix my problem. It was quite simple actually. Some replies say to place the local.properties file in the project root. Your project root isn't in /../projectlocation, but in /../projectlocation/android, if you're building for android. After moving my local.properties from /projectlocation to /projectlocation/android, it works.
The current version (1.2.1.1) of Android Studio allows me to build sample apps using the NDK, but I have noticed that each time I load a new project, I must set ndk.dir=/path/to/ndk/install in my local.properties file for Gradle to detect the NDK, whereas the sdk path is auto-populated.
Is there a way to set this globally via a preference or ENV variable? I could not find any indication that there is
in the latest release of android studio 1.3 you can set NDK path directly
in windows press ctrl+shift+alt+s which will open project properties where you can find first option named SDK Location click on it and there you can see space where you can add NDK location
If you set the environment variable ANDROID_HOME to the location of your SDK and ANDROID_NDK_HOME to the location of your NDK, and delete any local.properties file, this builds projects with native code as expected on my Android Studio 1.2. I don't know why gradle clears other property setting mechanisms when a local.properties file is present.
An alternative to this would be to replace the local.properties file with a link to a master properties file.
Note that this may all be changing when the new native code support arrives in Android Studio 1.3.