如何设置 ANDROID_SDK_HOME 环境变量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23042638/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:43:12  来源:igfitidea点击:

How do I set ANDROID_SDK_HOME environment variable?

androideclipsewindows-7sdkadt

提问by OlegArsyonov

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

我正在 Windows 7 x64 上使用 Eclipse。运行 ADT android 开发包时出现错误:

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

错误:解析 AVD 时出错
无法获取 Android SDK 主目录。
确保环境变量 ANDROID_SDK_HOME 已设置。

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

我知道问题是什么。是不是因为它链接到了错误的目录 C:users:????

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

如何将此环境变量 android_sdk_home 设置为正确的目录?

Please give me precise steps on how to do it such as open cmd.exe, type this etc. I'm not good at it, I've never coded anything other that websites.

请给我具体的操作步骤,例如打开cmd.exe、输入等。我不擅长它,我从来没有编写过其他网站的代码。

回答by Yousha Aleayoub

ANDROID_HOME

ANDROID_HOME

Deprecated(in Android Studio), use ANDROID_SDK_ROOTinstead.

已弃用(在 Android Studio 中),请ANDROID_SDK_ROOT改用。

ANDROID_SDK_ROOT

ANDROID_SDK_ROOT

Installation directory of Android SDKpackage.

Android SDK包的安装目录。

Example: C:\AndroidSDKor ~/android-sdk/

示例:C:\AndroidSDK~/android-sdk/

ANDROID_NDK_ROOT

ANDROID_NDK_ROOT

Installation directory of Android NDKpackage. (WITHOUT ANY SPACE)

Android NDK包的安装目录。(没有任何空间)

Example: C:\AndroidNDKor ~/android-ndk/

示例:C:\AndroidNDK~/android-ndk/

ANDROID_SDK_HOME

ANDROID_SDK_HOME

Location of SDK related data/userfiles.

SDK 相关数据/用户文件的位置。

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

示例:C:\Users\<USERNAME>\.android\~/.android/

ANDROID_EMULATOR_HOME

ANDROID_EMULATOR_HOME

Location of emulator-specificdatafiles.

位置特定仿真器,数据文件。

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

示例:C:\Users\<USERNAME>\.android\~/.android/

ANDROID_AVD_HOME

ANDROID_AVD_HOME

Location of AVD-specificdatafiles.

位置AVD-特定的数据文件。

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

示例:C:\Users\<USERNAME>\.android\avd\~/.android/avd/

JDK_HOMEand JAVA_HOME

JDK_HOMEJAVA_HOME

Installation directory of JDK(aka Java SDK) package.

JDK(又名Java SDK)包的安装目录。

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

注意:这用于运行 Android Studio(和其他基于 Java 的应用程序)。其实,当你运行Android Studio中,它会检查JDK_HOME,然后JAVA_HOME环境变量来使用。

回答by OlegArsyonov

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
  1. 打开控制面板
  2. 然后进入系统
  3. 然后转到更改用户的环境变量
  4. 然后点击创建新的环境变量
  5. 创建一个名为 ANDROID_SDK_HOME 的新变量
  6. 将其值设置为您的 Android 目录,例如 C:/users/<username>/.android

回答by Militant Saungweme

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
  1. 打开控制面板
  2. 点击系统
  3. 然后转到更改环境变量
  4. 然后点击创建新的环境变量
  5. 创建一个名为 ANDROID_HOME 路径 C:\Android\sdk 的新变量

回答by e-cloud

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

打开您的广告并打开首选项,然后使用您的 sdk 目录修改目录,它可能会帮助您按照图片链接指示进行操作

enter image description here

在此处输入图片说明

回答by Hitesh Sahu

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

复制您的 SDK 路径并将其分配给环境变量ANDROID_SDK_ROOT

Refer pic below:

参考下图:

enter image description here

在此处输入图片说明

回答by oasisfleeting

Android SDK

安卓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.

还需要安装 Android SDK。Android SDK 为您提供了为 Android 构建、测试和调试应用程序所需的 API 库和开发人员工具。

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

Cordova 需要设置ANDROID_HOME环境变量。这应该指向[ANDROID_SDK_DIR]\android-sdk目录(例如 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%\toolsand %ANDROID_HOME%\platform-tools.

接下来,更新您的 PATH 以在该文件夹中包含 tools/ 和 platform-tools/ 文件夹。因此,使用ANDROID_HOME,您将同时添加%ANDROID_HOME%\tools%ANDROID_HOME%\platform-tools

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

参考:http: //ionicframework.com/docs/v1/guide/installation.html

回答by Divakar Rajesh

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
  1. 右键单击此电脑-> 属性
  2. 在左侧窗格中选择“高级系统设置”
  3. 在新窗口中选择 -> 高级选项卡
  4. 单击“环境变量”按钮
  5. 在第一个顶部点击“新建”按钮

set variable name -> ANDROID_HOME

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

设置变量名称 -> ANDROID_HOME

设置变量值 -> 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

  1. 现在单击新创建的变量名称,然后在下面的框中选择“路径”,然后单击“编辑”按钮
  2. 现在点击新建并粘贴“平台工具”的位置
  3. 再次点击新建并粘贴“工具”的位置,你可以找到上述平台工具和工具的位置——它们一般在Android SDK文件夹内
  4. 最重要的...

    单击确定保存所有这些如果您正在使用终端(cmd)关闭它并再次打开它

回答by user3076495

from command prompt:

从命令提示符:

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

设置 ANDROID_SDK_HOME=C:\[无论您的 sdk 文件夹在哪里]

should do the trick.

应该做的伎俩。

回答by Jawad Multani

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

AVD 找不到 SDK 根目录,可能是因为它们在不同的目录中。如下面的屏幕截图所示设置环境变量:

enter image description here

在此处输入图片说明