简体   繁体   English

Cordova问题无法添加平台android

[英]Cordova issue can't add platform android

C:\Users\pratik.agrawal\AppData\Roaming\npm>cordova create hello com.example.hello HelloWorld
Creating a new cordova project with name "HelloWorld" and id "com.example.hello" at location "C:\Users\pratik.agrawal\AppData\Roaming\npm\hello"
Downloading cordova library for www...
Download complete

C:\Users\pratik.agrawal\AppData\Roaming\npm>cd hello

C:\Users\pratik.agrawal\AppData\Roaming\npm\hello>cordova platform add android
'cordova' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\pratik.agrawal\AppData\Roaming\npm\hello>

Before running any command-line tools , you need to install SDKs for each platform you wish to target. 在运行任何命令行工具之前 ,您需要为要定位的每个平台安装SDK。 Say Android Android

To install the cordova command-line tool, follow these steps: 要安装cordova命令行工具,请按照下列步骤操作:

Download and install Node.js . 下载并安装Node.js. Following installation, you should be able to invoke node or npm on your command line. 安装之后,您应该能够在命令行上调用node或npm。

Install the cordova utility. 安装cordova实用程序。 In Unix, prefixing the additional sudo command may be necessary to install development utilities in otherwise restricted directories: 在Unix中,在其他受限制的目录中安装开发实用程序可能需要添加额外的sudo命令前缀:

 For Mac $ sudo npm install -g cordova

 For Windows >npm install -g cordova

once successful installation of cordova is done ,now you can create your application 完成cordova的成功安装后,现在您可以创建应用程序了

across all the platforms. 跨所有平台。

Create the Cordova Application 创建Cordova应用程序

Go to the directory where you maintain your source code, and run a command such as the following: 转到维护源代码的目录,然后运行如下命令:

 $cordova create hello com.example.hello CordovaDemo

hello is the directory where you want to create your application hello是您要创建应用程序的目录

com.example.hello is the package name com.example.hello是包名

CordovaDemo is the name of the Application CordovaDemo是应用程序的名称

Add Platforms 添加平台

All subsequent commands need to be run within the project's directory, or any sub directories within its scope: 所有后续命令都需要在项目目录或其范围内的任何子目录中运行:

 $ cd hello

Then 然后

$ cordova platform add android

Hope this will help you. 希望这会帮助你。

For people visiting this question from google, the specific problem here was that after the global install from npm, the cordova binary was not visible in other directories. 对于从谷歌访问此问题的人来说,这里的具体问题是在从npm进行全局安装之后,cordova二进制文件在其他目录中不可见。 The path to the directory where cordova was installed had to be manually added to the path (see comments on OP). 必须手动将安装cordova的目录路径添加到路径中(请参阅OP上的注释)。

This is a Unresolved cordova bug already posted in jira -platform add android fails on Mac with JAVA_HOME error. 这是一个未解决的cordova错误已经发布在jira -platform上添加android失败在Mac上有JAVA_HOME错误。 check this https://issues.apache.org/jira/browse/CB-5422 检查这个https://issues.apache.org/jira/browse/CB-5422

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM