68

I'm working with Eclipse on Windows 7, x64. I'm getting an error when running ADT bundle of android development:

Error: Error parsing the AVDs
Unable to get the Android SDK home directory.
Make sure the environment variable ANDROID_SDK_HOME is set up.

I know what the issue is. Is it because it is linked to a wrong directory C:users:????

How do I set this environment variable android_sdk_home to the proper directory?

OlegArsyonov
  • 1,251
  • 1
  • 14
  • 18
  • Kindly go to this thread [http://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7?rq=1](http://stackoverflow.com/questions/2619584/how-to-set-java-home-on-windows-7?rq=1) – M D Apr 13 '14 at 12:23
  • wait for a while i'll give you all the stpes – M D Apr 13 '14 at 12:28
  • @OlegArsyonov - I was not aware Android used `ANDROID_SDK_HOME`. I know it *does* use `ANDROID_HOME`, `ANDROID_SDK_ROOT` and `ANDROID_NDK_ROOT`, and the last two should be set because the tools internally use them. Where did you latch onto `ANDROID_SDK_HOME`? Here's the reference on `ANDROID_SDK_ROOT` and `ANDROID_NDK_ROOT`: [Recommended NDK Directory?](https://groups.google.com/d/msg/android-ndk/qZjhOaynHXc/2ux2ZZdxy2MJ). The fellow named Digit works on the NDK team. – jww Dec 27 '14 at 03:36
  • Also see [SDK Manager.exe doesn't work](http://stackoverflow.com/a/27664180/608639) – jww Dec 27 '14 at 03:54

13 Answers13

136

ANDROID_HOME

Installation directory of Android SDK package.

Example: C:\AndroidSDK or /usr/local/android-sdk/

ANDROID_USER_HOME

Location of SDK related data/user files.

Example: C:\Users\<USERNAME>\.android\ or ~/.android/

ANDROID_SDK_ROOT

Deprecated (in Android Studio), use ANDROID_HOME instead.

ANDROID_NDK_ROOT

Installation directory of Android NDK package. (WITHOUT ANY SPACE)

Example: C:\AndroidNDK or /usr/local/android-ndk/

ANDROID_SDK_HOME

Deprecated (in Android Studio 4.2), use ANDROID_PREFS_ROOT instead.

ANDROID_PREFS_ROOT

Deprecated (in Android Studio), use path to subdirectory .android via ANDROID_USER_HOME instead.

Example: C:\Users\<USERNAME>\ or ~/

ANDROID_EMULATOR_HOME

Location of emulator-specific data files.

Example: C:\Users\<USERNAME>\.android\ or ~/.android/

ANDROID_AVD_HOME

Location of AVD-specific data files.

Example: C:\Users\<USERNAME>\.android\avd\ or ~/.android/avd/

JDK_HOME and JAVA_HOME

Installation directory of JDK (aka Java SDK) package.

Note: This is used to run Android Studio(and other Java-based applications). Actually when you run Android Studio, it checks for JDK_HOME then JAVA_HOME environment variables to use.

User Rebo
  • 3,056
  • 25
  • 30
Yousha Aleayoub
  • 4,532
  • 4
  • 53
  • 64
  • 10
    I had a difficult time getting Android Studio respecting these environment variables. I would set the `ANDROID_SDK_HOME` but Android Studio would still want to create AVDs in the `~/.android/avd` directory. Any idea what could be the issue? I ended up using a symlink from `~/.android` to my desired directory. – Joshua Pinter Apr 07 '18 at 16:33
  • 1
    @JoshuaPinter I had same issue, somehow Android Studio is not honoring any of these environment variables, at last symlink worked well. – binary Nov 13 '18 at 20:40
  • Created a symbolic link using `ln -s $ANDROID_SDK_HOME ~/.android` – Zack Aug 13 '19 at 15:15
  • 3
    Worked for me! Also great to read up here: https://developer.android.com/studio/command-line/variables#android_sdk_root – Vigs Feb 05 '20 at 04:12
  • 1
    On windows look in AppData\Local\Android\ – 9 Guy Feb 03 '21 at 11:19
28

If you face the same error, here are the step by step instructions:

  1. Open control panel
  2. Then go to System
  3. Then go to Change Environment Variables of the User
  4. Then click create a new environment variables
  5. Create a new variable named ANDROID_SDK_HOME
  6. Set its value to your Android directory, like C:/users/<username>/.android
jww
  • 97,681
  • 90
  • 411
  • 885
OlegArsyonov
  • 1,251
  • 1
  • 14
  • 18
  • 3
    If this is the answer, then you should accept your own answer. That's how Stack Overflow works. See [How does accepting an answer work?](http://meta.stackexchange.com/q/5234/173448). – jww Dec 27 '14 at 03:22
  • 4
    This does not look quite right: `C:/users//.android`. That looks like the `ANDROID_HOME` directory, and not the SDK directory. The SDK directory would be `ANDROID_SDK_ROOT`. Here's the reference on `ANDROID_SDK_ROOT` and `ANDROID_NDK_ROOT`: [Recommended NDK Directory?](https://groups.google.com/d/msg/android-ndk/qZjhOaynHXc/2ux2ZZdxy2MJ). The fellow named Digit works on the NDK team. – jww Dec 27 '14 at 03:31
  • 1
    @jww - did you read the thread you linked? It never even references `ANDROID_HOME`. It only refers to 3 variables as 'standard.' In addition, it specifies `ANDROID_SDK_HOME` as equaling `~/.android/` on Linux, which corresponds to `%USERPROFILE%\.android` on Windows. The fact is that, you don't need to specify the `.android` subfolder. On Windows, you just set `ANDROID_SDK_HOME` to whatever folder it resides in. So, in the OP's case, it would be set to `C:\Users\` or `%UserProfile%` and for others, wherever you like. The only caveat is that the (parent) folder must exist. – Frank May 20 '16 at 04:30
  • @Frank - yes, I read it (it was my question to the NDK folks). `ANDROID_SDK_ROOT` is the one variable I am aware of that Android uses to determine the SDK location. Who knows what `ANDROID_SDK_HOME` is. Eclipse [does not document it](http://www.google.com/search?q="ANDROID_SDK_HOME"+site:eclipse.org), and its not obvious to me why yet another variable is needed. My best guess is you should set `ANDROID_SDK_HOME` to `ANDROID_SDK_ROOT`. – jww May 20 '16 at 16:25
19

Copy your SDK path and assign it to the environment variable ANDROID_SDK_ROOT

Refer pic below:

enter image description here

Hitesh Sahu
  • 41,955
  • 17
  • 205
  • 154
9

This worked for me:

  1. Open control panel
  2. click System
  3. Then go to Change Environment Variables
  4. Then click create a new environment variables
  5. Create a new variable named ANDROID_HOME path C:\Android\sdk
  • @Kartiikeya, No, anywhere. But given path shouldnt contain `space`. – Yousha Aleayoub Aug 24 '16 at 22:49
  • ANDROID_HOME will work if the path is correct. If the path is incorrect or is unable to find ANDROID_HOME it will look for ANDROID_SDK_HOME. That is why it works if you have either set correctly. – Snappy Cracker Oct 03 '17 at 22:37
8

open your adt and open preferences, then modify directory with your sdk dir, it may help you follow the pic link indication

enter image description here

e-cloud
  • 4,331
  • 1
  • 23
  • 37
6

Just set the path to the Android SDK directory

flutter config --android-sdk c:\android\sdk

5

Android SDK

Installing the Android SDK is also necessary. The Android SDK provides you the API libraries and developer tools necessary to build, test, and debug apps for Android.

Cordova requires the ANDROID_HOME environment variable to be set. This should point to the [ANDROID_SDK_DIR]\android-sdk directory (for example c:\android\android-sdk).

Next, update your PATH to include the tools/ and platform-tools/ folder in that folder. So, using ANDROID_HOME, you would add both %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools.

Reference : http://ionicframework.com/docs/v1/guide/installation.html

oasisfleeting
  • 999
  • 12
  • 6
5

Although the above answers mostly get them right, there is one slight issue with them all.. Follow these steps and you are good to go

  1. Right click on This PC -> Properties
  2. On the left pane select "Advanced System Settings"
  3. On the new window select -> Advanced tab
  4. Click on the "Environment Variables" button
  5. On the first top section click on the "New" button

set variable name -> ANDROID_HOME

set variable value -> the custom location of the Android SDK

  1. Now click on the newly created variable name and in the box below select "Path" and click on the Edit button
  2. Now click on New and paste the location of the "platform-tools"
  3. Again click on New and paste the location of the "tools" You can find the locations of the above platform-tools and tools - they are generally inside the Android SDK folder
  4. MOST IMPORTANT OF ALL...

    save all those by clicking ok If you are using the terminal(cmd) close it and open it again

Divakar Rajesh
  • 1,140
  • 2
  • 18
  • 23
4

from command prompt:

set ANDROID_SDK_HOME=C:\[wherever your sdk folder is]

should do the trick.

  • Whether the location should be in C drive ? – Kartiikeya Jun 09 '16 at 13:02
  • READ before commenting for the love of Martha. Several comments above tell you how to find the location of your particular SDK location. set ANDROID_SDK_HOME=C:\[wherever your sdk folder is] and that is explained above, look just above at the large image. – Snappy Cracker Oct 03 '17 at 22:40
4

AVD cant find SDK root, possibly because they are in different directories.Set your environment variables as shown in the screenshot below:

enter image description here

Mazin Ibrahim
  • 7,433
  • 2
  • 33
  • 40
0

Just Simple Steps

Follow this steps:

1.Right-click on 'My Computer'/'This PC' and select Properties. Go to Advanced system settings and select ‘Environmental Variables’ option

Environmental Variables

2.Under the User Variable table, click New to open New User Variable dialog

3.Put ANDROID_HOME as Variable name and provide the path of the SDK folder next to Variable value.

opened dialog box

4.Close the entire opened dialog box.

Follow this link for complete example

https://sndevelops.blogspot.com/2021/05/set-androidhome-and-path-variables.html

  • 1
    Snehal wadbudhe, a link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it is there, then quote the most relevant part of the page you are linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](/help/deleted-answers) – 4b0 May 21 '21 at 05:49
  • Another way to open the Advanced Properties is by using the Win+R keyboard shortcut and typing the command "sysdm.cpl ,3". – Ola Ström Nov 29 '21 at 10:21
  • But I guess you should use ANDROID_SDK_ROOT instead of ANDROID_HOME, see below answers. – Ola Ström Nov 29 '21 at 10:35
0

In my case, all Android Licenses were not accepted

flutter doctor --android-licenses

accept all licences and then try:

flutter build appbundle
Riya Gupta
  • 69
  • 3
0

If Your flutter in vscode (Mac Os) Not Want to Trouble Anything !..

  1. Open Extensions
  2. Search For "Android Emulator"
  3. Install "Android Emulator Launcher"

If you already installed then Uninstall it and Newly install it there !!

It Worked For me...

Shadeer
  • 69
  • 1
  • 3