简体   繁体   English

“错误:命令“ android”失败”使用cordova

[英]'Error: the command “android” failed' using cordova

I'm trying to get the android platform added on cordova. 我正在尝试在cordova上添加android平台。 I've added and downloaded the most recent SDK in Android SDK, my path is : export PATH=${PATH}:/Users/xxx/Development/android-sdk-macosx/platform-tools:Users/xxx/Development/android-sdk-macosx/tools , but I keep getting the following error: 我已经添加并下载了Android SDK中最新的SDK,我的路径是: export PATH=${PATH}:/Users/xxx/Development/android-sdk-macosx/platform-tools:Users/xxx/Development/android-sdk-macosx/tools ,但我不断收到以下错误:

Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
    at /Users/xxx/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:85:29
    at _rejected (/Users/xxx/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:808:24)
    at /Users/xxx/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:834:30
    at Promise.when (/Users/xxx/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:1079:31)
    at Promise.promise.promiseDispatch (/Users/xxx/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:752:41)
    at /Users/xxx/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44
    at flush (/Users/xxx/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:419:13)
Error: /Users/xxx/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8
    at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:755:16)
    at Process.ChildProcess._handle.onexit (child_process.js:822:5)

What am I doing wrong? 我究竟做错了什么? I've search all over for answers, but nothing seems to work. 我到处都在寻找答案,但似乎没有任何效果。 Thanks in advance! 提前致谢!

In case of Apache Cordova with Android Studio 0.8 for Mac OS X 10.9, if you have installed in the default /Applications folder, run this on Terminal 如果使用适用于Mac OS X 10.9的Android Studio 0.8的Apache Cordova ,则如果已安装在默认的/ Applications文件夹中,请在终端上运行

export ANDROID_HOME="/Applications/Android Studio.app/sdk"
export ANDROID_TOOLS="/Applications/Android Studio.app/sdk/tools/"
export ANDROID_PLATFORM_TOOLS="/Applications/Android Studio.app/sdk/platform-tools/"
PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS

To confirm, run echo and get 要确认,请运行echo并获取

echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/Android Studio.app/sdk:/Applications/Android Studio.app/sdk/tools/:/Applications/Android Studio.app/sdk/platform-tools/

For Cordova 3.6, it threw another error on a fresh Android Studio 对于Cordova 3.6,它在全新的Android Studio上引发了另一个错误

Error: Please install Android target "android-19"

To resolve this, open SDK manager in the IDE, and download the mentioned android version (android-19) 要解决此问题,请在IDE中打开SDK管理器,然后下载提到的android版本(android-19)

the android command is part of the android sdk's tools package. android命令是android sdk工具包的一部分。 Both android and adb are used by the Cordova tools to work their magic and both need to be put on the path. Cordova工具使用androidadb来发挥其魔力,并且两者都需要放在路径上。

They are located in the following directories: 它们位于以下目录中:

path/to/android/sdk/tools
path/to/android/sdk/platform-tools  

I don't know what OS you are developing on. 我不知道您正在开发什么操作系统。 The process for modifying the path is different on windows and unix based systems 在Windows和基于UNIX的系统上,修改路径的过程有所不同

add to path on unix-like systems 在类Unix系统上添加到路径

On my system (OSX) this is done by adding the following lines to .bash_profile : 在我的系统(OSX)上,这是通过向.bash_profile添加以下行来完成的:

PATH=$PATH:/Users/lorenzo/dev/sdks/adt-bundle/sdk/tools
PATH=$PATH:/Users/lorenzo/dev/sdks/adt-bundle/sdk/platform-tools

this could also be done in a single line: 这也可以在一行中完成:

PATH=$PATH:/Users/lorenzo/dev/sdks/adt-bundle/sdk/tools:/Users/lorenzo/dev/sdks/adt-bundle/sdk/platform-tools

this appends the path strings to the global PATH variable. 这会将路径字符串附加到全局PATH变量。 On unix the path delimiter is ':' 在Unix上,路径分隔符为':'

add to path on windows 在Windows上添加到路径

much the same process, here is the official docs: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682653%28v=vs.85%29.aspx 大致相同的过程,这是官方文档: http : //msdn.microsoft.com/zh-cn/library/windows/desktop/ms682653%28v=vs.85%29.aspx

additional reading and next steps 其他阅读和后续步骤

This blog article will walk you through path setup, and is up to date. 这篇博客文章将引导您完成路径设置,并且是最新的。

You can look at the Getting Started guide for Cordova Android , which details how to add the necessary components to your path. 您可以查看Cordova Android入门指南 ,其中详细介绍了如何在路径中添加必要的组件。

After your path is setup, you will need to run the android tool and install additional tools and android platforms (versions). 设置路径后,您将需要运行android工具并安装其他工具和android平台(版本)。

Your system will need Apache ANT and the java run time as well. 您的系统将需要Apache ANT和Java运行时。

Note that these are not cordova specific requirements, but requirements for Android development with the SDK. 请注意,这些并非Cordova特定要求,而是使用SDK开发Android的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Android模拟器上运行Cordova错误:“android:命令失败,退出代码为2” - Cordova error running on android emulator: “android: Command failed with exit code 2” cordova / platforms / android / gradlew:命令失败,退出代码为1错误输出: - cordova /platforms/android/gradlew: Command failed with exit code 1 Error output: 流星建筑失败Cordova应用程序的平台Android:命令的错误代码1: - meteor building failed Cordova app for platform Android: Error code 1 for command: Cordova - 命令的错误代码 1 | 命令失败 - Cordova - Error code 1 for command | Command failed for 科尔多瓦建立Android命令错误 - cordova build android command error 科尔多瓦添加平台android命令失败 - cordova add platforms android command failed Cordova-错误:cmd:命令失败,退出代码为1 - Cordova - Error: cmd: Command failed with exit code 1 Cordova / PhoneGap-生成命令的错误代码1 - Cordova/PhoneGap - Build failed Error code 1 for command cordova build android 错误:系统找不到指定的路径。 错误:cmd:命令失败,退出代码为 1 - cordova build android error : The system cannot find the path specified. Error: cmd: Command failed with exit code 1 尝试构建Android应用程序时,Cordova失败,错误为“命令失败,退出代码2”,Linux - Cordova fail when try to build Android app with error “Command failed with exit code 2” Linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM