无法识别路径中的 android 命令
Does not recognize android command in path
我正在尝试构建我的第一个 cordova 项目,当我在项目文件夹中时,我提示:
sudo cordova build android
我收到以下错误:
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/veritopsecret/hello/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
当我执行 echo $PATH 时,我得到:
veritopsecret@veritopsecret-SATELLITE-PRO-C50-A-1HQ:~/hello$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/veritopsecret/Escriptori/android-sdk-linux/tools:/home/veritopsecret/Escriptori/android-sdk-linux/platform-tools
我也修改了 .profile 文件,但它仍然说它在 PATH 中没有 android 命令。但是,如果我只写 android,它会打开 android sdk 管理器。请帮忙!!
当我重新阅读你的问题时,我看到了你 运行 sudo cordova build android
我认为您遇到的问题是您定义了 ANDROID_HOME 并将 android 工具添加到您的用户路径,然后您使用 sudo 来 运行 构建。
sudo 运行s 具有提升的权限,使用的用户不是您登录时使用的用户配置文件,因此未设置路径和 ANDROID_HOME。 (也许可以尝试 sudo echo $PATH
来确定这一点)。
因此,如果您真的想使用 sudo 进行构建,则需要为 sudo 用户定义变量或改用 sudo -E(有关详细信息,请参阅此页面:https://wiki.archlinux.org/index.php/Sudo#Environment_variables)
但实际上,您应该只在安装 cordova 时使用 sudo,而不是在使用 CLI 时使用。
所以,只要 运行 cordova build android
一切都应该没问题。
我正在尝试构建我的第一个 cordova 项目,当我在项目文件夹中时,我提示: sudo cordova build android 我收到以下错误:
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/veritopsecret/hello/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
当我执行 echo $PATH 时,我得到:
veritopsecret@veritopsecret-SATELLITE-PRO-C50-A-1HQ:~/hello$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/veritopsecret/Escriptori/android-sdk-linux/tools:/home/veritopsecret/Escriptori/android-sdk-linux/platform-tools
我也修改了 .profile 文件,但它仍然说它在 PATH 中没有 android 命令。但是,如果我只写 android,它会打开 android sdk 管理器。请帮忙!!
当我重新阅读你的问题时,我看到了你 运行 sudo cordova build android
我认为您遇到的问题是您定义了 ANDROID_HOME 并将 android 工具添加到您的用户路径,然后您使用 sudo 来 运行 构建。
sudo 运行s 具有提升的权限,使用的用户不是您登录时使用的用户配置文件,因此未设置路径和 ANDROID_HOME。 (也许可以尝试 sudo echo $PATH
来确定这一点)。
因此,如果您真的想使用 sudo 进行构建,则需要为 sudo 用户定义变量或改用 sudo -E(有关详细信息,请参阅此页面:https://wiki.archlinux.org/index.php/Sudo#Environment_variables)
但实际上,您应该只在安装 cordova 时使用 sudo,而不是在使用 CLI 时使用。
所以,只要 运行 cordova build android
一切都应该没问题。