未能找到“ANDROID_HOME"环境变量 [英] Failed to find 'ANDROID_HOME' environment variable
问题描述
我正在尝试构建一个 ionic-android 项目并且我已经安装了 android sdk.
I am trying to build an ionic-android project and i have android sdk installed.
我的项目名称是 myApp.我已经成功地将 android 平台添加到 myApp.但是当我尝试构建项目时
The name of my project is myApp.I have successfully added android platform to myApp. But when i tries to build the project
~/myApp$ sudo ionic build android
结果是
Running command: /home/hari/myApp/hooks/after_prepare/010_add_platform_class.js /home/hari/myApp
add to body class: platform-android
ERROR building one of the platforms: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
You may not have the required environment or OS to build this project
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
查看 ANDROID_HOME 和 PATH 变量
see the ANDROID_HOME and PATH variable
echo $ANDROID_HOME
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/hari/Android/Sdk
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/hari/Android/Sdk/tools:/home/hari/Android/Sdk/platform-tools:/usr/local/bin:/opt/gradle/bin
我在堆栈溢出方面看到了几乎相同类型的问题,但没有一个对我有用.我的 android-sdk 配置有什么问题吗?我怎样才能建立这个项目?
I have seen almost the same kind of questions on stack overflow, but none works for me. Is there anything wrong with my android-sdk configuration? How can i build this project?
推荐答案
您可能需要确认您的开发环境已正确设置.
You may want to confirm that your development environment has been set correctly.
引自 spring.io:
在构建 Android 应用程序之前,您必须安装安卓软件开发工具包.安装 Android SDK 也会安装 AVD Manager,用于创建和管理 Android Virtual 的图形用户界面设备 (AVD).
Set up the Android development environment
Before you can build Android applications, you must install the Android SDK. Installing the Android SDK also installs the AVD Manager, a graphical user interface for creating and managing Android Virtual Devices (AVDs).
从 Android 网站,下载适用于您的操作系统的正确版本的 Android SDK.
From the Android web site, download the correct version of the Android SDK for your operating system.
将存档解压缩到您选择的位置.例如,在 Linux 或 Mac 上,您可以将其放在用户目录的根目录中.看Android开发者有关其他安装详细信息的网站.
Unzip the archive to a location of your choosing. For example, on Linux or Mac, you can place it in the root of your user directory. See the Android Developers web site for additional installation details.
根据 Android SDK 的位置配置 ANDROID_HOME
环境变量.此外,考虑添加ANDROID_HOME/tools
和 ANDROID_HOME/platform-tools
到您的 PATH.
Configure the ANDROID_HOME
environment variable based on the location of the Android SDK. Additionally, consider adding
ANDROID_HOME/tools
, and ANDROID_HOME/platform-tools
to your PATH.
Mac OS X
export ANDROID_HOME=/<installation location>/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Linux
export ANDROID_HOME=/<installation location>/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
视窗
set ANDROID_HOME=C:<installation location>android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME% ools;%ANDROID_HOME%platform-tools
Android SDK 下载不包括特定的 Android 平台.要运行本指南中的代码,您需要下载并安装最新的SDK平台.您可以使用 Android SDK 和 AVD 来完成此操作您在上一节中安装的管理器.
The Android SDK download does not include specific Android platforms. To run the code in this guide, you need to download and install the latest SDK platform. You do this by using the Android SDK and AVD Manager that you installed in the previous section.
打开 Android SDK 管理器窗口:
android
注意:如果这个命令没有打开Android SDK Manager,那么你的路径配置不正确.
Note: If this command does not open the Android SDK Manager, then your path is not configured correctly.
选中工具复选框.
选中最新 Android SDK 的复选框.
从 Extras 文件夹中,选中 Android 支持库 的复选框.
From the Extras folder, select the checkbox for the Android Support Library.
点击安装包...按钮完成下载和安装.
Click the Install packages... button to complete the download and installation.
注意:您可能想要安装所有可用的更新,但意识到这将需要更长的时间,因为每个 API 级别都是一次大下载.
Note: You may want to install all the available updates, but be aware it will take longer, as each API level is a large download.
这篇关于未能找到“ANDROID_HOME"环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!