gpt4 book ai didi

android - 找不到 'ANDROID_HOME' 环境变量

转载 作者:IT老高 更新时间:2023-10-28 13:02:04 25 4
gpt4 key购买 nike

我正在尝试构建一个 ionic-android 项目,并且我已经安装了 android sdk。

SDK manager installed packages

我的项目名称是myApp。我已成功将android平台添加到myApp。但是当我尝试构建项目时

~/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 变量

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 配置有什么问题吗?我该如何构建这个项目?

最佳答案

您可能需要确认您的开发环境已正确设置。

引自 spring.io :

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).

  1. From the Android web site, download the correct version of the Android SDK for your operating system.

  2. 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.

  3. 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

Windows

set ANDROID_HOME=C:\<installation location>\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

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.

  1. Open the Android SDK Manager window:

    android

    Note: If this command does not open the Android SDK Manager, then your path is not configured correctly.

  2. Select the Tools checkbox.

  3. Select the checkbox for the latest Android SDK.

  4. From the Extras folder, select the checkbox for the Android Support Library.

  5. Click the Install packages... button to complete the download and installation.

    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 - 找不到 'ANDROID_HOME' 环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36198165/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com