Phonegap Cordova 安装 Windows
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18035566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Phonegap Cordova installation Windows
提问by frigon
The documentation for phonegap/cordova is absolutely horrible. All I'm trying to do is install PhoneGap 3.0 on my Windows environment but having no success.
phonegap/cordova 的文档绝对是可怕的。我想要做的就是在我的 Windows 环境中安装 PhoneGap 3.0,但没有成功。
Below are my steps and points of failure. Can anyone advise on solutions?
以下是我的步骤和失败点。任何人都可以就解决方案提出建议吗?
According to the instructions:
根据说明:
- Install Node.js (SUCCESSFUL)
- From nodes.js:
install -g cordova
(SUCCESSFUL) - Add Platform:
cordova platform add wp8
(NOTHING HAPPENS) - Try with phonegap:
phonegap install wp8
(ERROR project directory could not be found)
- 安装 Node.js(成功)
- 来自nodes.js:(
install -g cordova
成功) - 添加平台:(
cordova platform add wp8
什么也没发生) - 尝试使用phonegap:(
phonegap install wp8
找不到错误项目目录)
From "Windows Phone 8 platform guide"
- Install Windows SDK (SUCCESSFUL)
- "Download and extract the latest copy of [PhoneGap. You will be working in the lib\windows-phone-8\wp8 subfolder, lib\windows-phone-8\wp7 contains the Windwos Phone 7 version of Cordova"
- 安装 Windows SDK(成功)
- “下载并解压缩 [PhoneGap 的最新副本。您将在 lib\windows-phone-8\wp8 子文件夹中工作,lib\windows-phone-8\wp7 包含 Windwos Phone 7 版本的 Cordova”
HUH?!?! What location is the directory in?!?! So I've found the undocumented phonegap directory buried in AppData\Local... and there IS a libs directory but there certainly is NOT any WP8 subfolders. Where would one install that from? Presumably the add platform command above, but add that simply returns me to a new command prompt.
哈?!?!目录在什么位置?!?!所以我发现了隐藏在 AppData\Local 中的未记录的 phonegap 目录......并且有一个 libs 目录,但肯定没有任何 WP8 子文件夹。从哪里安装?大概是上面的 add platform 命令,但是 add 只会让我返回一个新的命令提示符。
Tried using the phonegap command: phonegap plaform add wp8
尝试使用 phonegap 命令: phonegap plaform add wp8
ERROR - 'platform add wp8" is not a node.
错误 - 'platform add wp8' 不是节点。
I get its open source but this is brutal spaghetti reference documentation. If anyone has been able to successfully install 3.0 for WP8 any pointers would be help.
我得到了它的开源,但这是残酷的意大利面参考文档。如果有人能够为 WP8 成功安装 3.0,任何指针都会有所帮助。
回答by frigon
After hours of frustration... here's what i discovered.
经过数小时的沮丧……这就是我发现的。
- Ignore the installation documentationand all the command line, node.js stuff (seriously you will waste hours on this.
- Go to github and simply download the PhoneGap master .zip
- In that zip are project files for window phone, etc platform... just use those templates.
- 忽略安装文档和所有命令行,node.js 的东西(说真的,你会在这上面浪费几个小时。
- 转到 github 并简单地下载PhoneGap master .zip
- 在那个 zip 中是窗口电话等平台的项目文件......只需使用这些模板。
I don't know how such an easy process could have worse documentation. It as if it was written by lawyers.
我不知道这样一个简单的过程怎么会有更糟糕的文档。好像是律师写的。
回答by binaryuser
I faced the same problem and struggled for an hour to get pass through by reading the documentsand the other issues reported in Stack Overflow but I didn't find any answer to it. So, here is the guide to successfully run the phonegap/cordova in Windows Machine.
我遇到了同样的问题,通过阅读文档和 Stack Overflow 中报告的其他问题,我挣扎了一个小时才能通过,但我没有找到任何答案。因此,这里是在 Windows 机器中成功运行 phonegap/cordova 的指南。
Follow these steps
按着这些次序
- Download and Install node.js from http://nodejs.org/
- Run the command
npm install -g phonegap
(in case of phonegap installation) or run the commandnpm install -g cordova
(in case of Cordova installation). As the installation gets completed you can notice this:
C:\Users\binaryuser\AppData\Roaming\npm\cordova -> C:\Users\binaryuser\AppData\Roaming\npm\node_modules\cordova\bin\cordova [email protected] C:\Users\binaryuser\AppData\Roaming\npm\node_modules\cordova ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ([email protected]) ├── [email protected] ([email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] └── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
Notice the above line you can see the path were the file is mentioned. Copy that path. In my case it is
C:\Users\binaryuser\AppData\Roaming\npm\cordova
so usecd C:\Users\binaryuser\AppData\Roaming\npm\
and typecordova
. There it is, it finally works.- Since the
-g
key value isn't working you have set the Environment Variables path:- Press Win+ Pause|Breakor right click on
Computer
and chooseProperties
. - Click
Advanced system settings
on the left. - Click
Environment Variables
under theAdvanced
tab. - Select the
PATH
variable and clickEdit
. - Copy the path mentioned above to the value field and press
OK
.
- Press Win+ Pause|Breakor right click on
- 从http://nodejs.org/下载并安装 node.js
- 运行命令
npm install -g phonegap
(在安装 phonegap 的情况下)或运行命令npm install -g cordova
(在安装 Cordova 的情况下)。 安装完成后,您可以注意到:
C:\Users\binaryuser\AppData\Roaming\npm\cordova -> C:\Users\binaryuser\AppData\Roaming\npm\node_modules\cordova\bin\cordova [email protected] C:\Users\binaryuser\AppData\Roaming\npm\node_modules\cordova ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] ([email protected]) ├── [email protected] ([email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected]) ├── [email protected] └── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
请注意上面的行,您可以看到提到文件的路径。复制那个路径。就我而言,它是
C:\Users\binaryuser\AppData\Roaming\npm\cordova
如此使用cd C:\Users\binaryuser\AppData\Roaming\npm\
和键入cordova
。就是这样,它终于起作用了。- 由于
-g
键值不起作用,您已设置环境变量路径:- 按Win+Pause|Break或右键单击
Computer
并选择Properties
。 - 点击
Advanced system settings
左侧。 - 单击选项卡
Environment Variables
下方Advanced
。 - 选择
PATH
变量并单击Edit
。 - 将上述路径复制到值字段并按
OK
。
- 按Win+Pause|Break或右键单击
回答by James Wong - Reinstate Monica
This answer was first posted here: cordova/phonegap does not make android directory
这个答案首先发布在这里:cordova/phonegap does not make android directory
With the release of Cordova 3.3.0, it seems the PhoneGap team is trying to address the naming confusion. The documentations have been updated to recommend people using the cordova
command instead. Do not use the command anymore.phonegap
随着 Cordova 3.3.0 的发布,PhoneGap 团队似乎正试图解决命名混乱问题。文档已更新以推荐使用该cordova
命令的人。不要再使用该命令。phonegap
Here is a fresh installation guide for a guaranteed trouble free set up:
这是保证无故障设置的全新安装指南:
Install Cordova (forget the name PhoneGap from now on). For PC:
C:> npm install -g cordova
From command prompt, navigate to the folder you want to create your project using:
cordova create hello com.example.hello HelloWorld cd hello
Define the OS you want to suppport for example:
cordova platform add wp8
Install plugins (If needed). For example we want the following:
cordova plugin add org.apache.cordova.device cordova plugin add org.apache.cordova.camera cordova plugin add org.apache.cordova.media-capture cordova plugin add org.apache.cordova.media
- Finally, generate the app using:
cordova build wp8
安装 Cordova(从现在开始忘记名称 PhoneGap)。个人电脑:
C:> npm install -g cordova
从命令提示符导航到要使用以下命令创建项目的文件夹:
cordova create hello com.example.hello HelloWorld cd hello
定义您要支持的操作系统,例如:
cordova platform add wp8
安装插件(如果需要)。例如,我们想要以下内容:
cordova plugin add org.apache.cordova.device cordova plugin add org.apache.cordova.camera cordova plugin add org.apache.cordova.media-capture cordova plugin add org.apache.cordova.media
- 最后,使用以下命令生成应用程序:
cordova build wp8
Here is a link to the PhoneGapCordova 3.3.0 Documentation
http://docs.phonegap.com/en/3.3.0/guide_cli_index.md.html#The%20Command-Line%20Interface
这是PhoneGapCordova 3.3.0 文档
的链接http://docs.phonegap.com/en/3.3.0/guide_cli_index.md.html#The%20Command-Line%20Interface
回答by Layinka
I faced this same error too. And i even tried downloading the PhoneGap master from GitHub,but i found out that what i got was Phonegap 2.9. I eventually had to download the Cordova 3 Source
我也遇到了同样的错误。我什至尝试从 GitHub 下载 PhoneGap master,但我发现我得到的是 Phonegap 2.9。我最终不得不下载Cordova 3 Source
Follow this steps to get it.
请按照以下步骤获取。
- Download and unzip the Cordova 3 Source
- Run the template.bat in the cordova-wp8 folder
- Copy the generated Zip files to your Visual studio template folder
- 下载并解压Cordova 3 源代码
- 运行cordova-wp8文件夹下的template.bat
- 将生成的 Zip 文件复制到 Visual Studio 模板文件夹
回答by Ajay Patel
Phonegap Cordova Installation on Windows
Windows 上的 Phonegap Cordova 安装
Requirements
要求
- Eclipse + ADT Plugin
- Android SDK Tool
- Android Platform Tools
- Latest PhoneGap zip folder. Extract its contents.
- Eclipse + ADT 插件
- 安卓SDK工具
- 安卓平台工具
- 最新的 PhoneGap zip 文件夹。提取其内容。
Supported Android Devices
支持的安卓设备
Android 2.2 Android 2.3 Android 4.x Phonegap Cordova Installation
Android 2.2 Android 2.3 Android 4.x Phonegap Cordova 安装
Set PATH environment variable for android
为android设置PATH环境变量
From desktop, right click My Computer and click Properties.
Click Advance System Settings link in the left column.
In the system properties window click the environment variables button.
Select the PATH variable from the System variables section. Select the Edit button. You need to add the path to your Android SDK platform-tools and tools directory. For Example: D:\adt-bundle-windows-x86_64-20130219\sdk\platform-tools;D:\adt-bundle-windows-x86_64-20130219\sdk\tools Save your Edit. Close the Environment Variable dialog.
- Additionally, you may need to include %JAVA_HOME%\bin to your PATH as well. To check to see if this is required run a command prompt and type java. If the program could not be found add %JAVA_HOME%\bin to the PATH. You may need to specify the full path instead of using %JAVA_HOME% environment variable.
- Finally, you may need to include %ANT_HOME%\bin to your PATH as well. To check to see if this is required run a command prompt and type ant. If program cannot be found then add %ANT_HOME%\bin to the PATH. You may need to specify the full path instead of using the %ANT_HOME% environment variable. Set-up New Project
在桌面上,右键单击我的电脑,然后单击属性。
单击左栏中的高级系统设置链接。
在系统属性窗口中单击环境变量按钮。
从系统变量部分选择 PATH 变量。选择编辑按钮。您需要将路径添加到您的 Android SDK 平台工具和工具目录。例如:D:\adt-bundle-windows-x86_64-20130219\sdk\platform-tools;D:\adt-bundle-windows-x86_64-20130219\sdk\tools 保存您的编辑。关闭环境变量对话框。
- 此外,您可能还需要将 %JAVA_HOME%\bin 包含到您的 PATH 中。要检查是否需要执行此操作,请运行命令提示符并键入 java。如果找不到该程序,请将 %JAVA_HOME%\bin 添加到 PATH。您可能需要指定完整路径而不是使用 %JAVA_HOME% 环境变量。
- 最后,您可能还需要将 %ANT_HOME%\bin 包含到您的 PATH 中。要检查是否需要执行此操作,请运行命令提示符并键入 ant。如果找不到程序,则将 %ANT_HOME%\bin 添加到 PATH。您可能需要指定完整路径而不是使用 %ANT_HOME% 环境变量。设置新项目
Open Command Prompt, navigate to bin directory within the android sub-folder of the Cordova distribution.
打开命令提示符,导航到 Cordova 发行版的 android 子文件夹中的 bin 目录。
Type in: ./create
输入:./create
Then press Enter.Launch Eclipse. In File Menu Item and select to Import…
然后按 Enter。启动 Eclipse。在文件菜单项中并选择导入...
Import Select “Existing Android Code into Workspace” and click ‘Next >'.
导入 选择“Existing Android Code into Workspace”,然后单击“Next >”。
Browse the project created through command prompt. And click ‘Finish'. Deploy to Emulator From within Eclipse, press this toolbar icon.
浏览通过命令提示符创建的项目。然后单击“完成”。部署到模拟器 在 Eclipse 中,按此工具栏图标。
Once open, the Android SDK Manager displays various runtime libraries Install the APIs as per requirement from here. From within Eclipse, press this toolbar icon.
打开后,Android SDK 管理器会显示各种运行时库,从此处按照要求安装 API。在 Eclipse 中,按此工具栏图标。
Choose and device definition from the list which comes. (There is only one item in the current list.) Press New… in the above window to create new Android Virtual Device(AVD) and use it to run your project.
从出现的列表中选择设备定义。(当前列表中只有一项。)在上面的窗口中按 New... 创建新的 Android Virtual Device(AVD) 并使用它来运行您的项目。
To open the emulator as a separate application, Select the AVD and press Start. It launches much as it would on device, with additional controls available for hardware buttons:
要将模拟器作为单独的应用程序打开,请选择 AVD 并按开始。它的启动方式与在设备上的启动方式非常相似,并为硬件按钮提供了额外的控件:
Deploy to Device:
部署到设备:
Make sure USB debugging is enabled on your device and plug it into your system. Right Click the Project and go to Run As > Android Application.
确保在您的设备上启用 USB 调试并将其插入您的系统。右键单击项目并转到运行方式 > Android 应用程序。
回答by Steve Drucker
In C:\phonegap-2.9.0\lib\windows-phone-8 there's
a batch file called createTemplates.bat
. You need to execute this file, which will create the CordovaWP8_2_9_0.zip
file mentioned in their docs.
在C:\phonegap-2.9.0\lib\windows-phone-8 there's
名为createTemplates.bat
. 您需要执行这个文件,这将创建CordovaWP8_2_9_0.zip
他们的文档中提到的文件。
回答by Altaf Hussain
I was having issues wtih installing phonegap. The issues were fixed when i run cmd as Administrator and then run command
我在安装 phonegap 时遇到了问题。当我以管理员身份运行 cmd 然后运行命令时,问题得到解决
npm install -g phonegap
and it is installed successfully.
并且安装成功。
Then in the directory where it is installed i opened cmd, and run command phonegap and it was working fine. Now going to play with it more :)
然后在安装它的目录中我打开 cmd,并运行命令 phonegap 并且它工作正常。现在要更多地玩它:)
Thanks buddies for all this help.
感谢所有这些帮助的朋友。
回答by Reva
I have found this Multi-Device Hybrid Apps for Visual Studio Documentation for CTP1.1 Last updated: May 29, 2014.
我找到了 CTP1.1 的 Visual Studio 文档的多设备混合应用程序 最后更新时间:2014 年 5 月 29 日。
Some of the content from the documentation as follows.
部分内容来自文档如下。
This release supports building apps for the following device targets:
此版本支持为以下设备目标构建应用程序:
Android 4+ (4.4 providing the optimal developer experience) iOS 6 & 7 Windows 8.0 (Store) Windows Phone 8.0
Android 4+ (4.4 提供最佳开发者体验) iOS 6 & 7 Windows 8.0 (Store) Windows Phone 8.0
Requirements:Windows 8.1
要求:Windows 8.1
Visual Studio 2013 Update 2 - Professional, Ultimate, or Premium with the following optional features installed:
Visual Studio 2013 Update 2 - Professional、Ultimate 或 Premium 安装了以下可选功能:
Tools for Maintaining Store apps for Windows 8 Windows Phone 8.0 SDK
用于维护 Windows 8 应用商店应用的工具 Windows Phone 8.0 SDK
Additional system requirements vary by device platform:
其他系统要求因设备平台而异:
The Android emulator works best with PCs capable of installing the Intel HAXM driver
Android 模拟器最适合能够安装 Intel HAXM 驱动程序的 PC
Windows Phone 8 requires a Hyper-V capable PC to run the emulator Building for iOS and using the iOS Simulator requires a Mac capable of running Xcode 5.1
Windows Phone 8 需要一台支持 Hyper-V 的 PC 来运行 iOS 模拟器构建,使用 iOS 模拟器需要一台能够运行 Xcode 5.1 的 Mac
Third Party Dependencies :
第三方依赖:
Joyent Node.js – Enables Visual Studio to integrate with the Apache Cordova Command Line Interface (CLI) and Apache Ripple? Emulator Git CLI – Required only if you need to manually add git URIs for plugins
Joyent Node.js – 使 Visual Studio 能够与 Apache Cordova 命令行界面 (CLI) 和 Apache Ripple 集成?模拟器 Git CLI – 仅当您需要为插件手动添加 git URI 时才需要
Google Chrome – Required to run the Apache Ripple emulator for iOS and Android
Google Chrome – 运行 iOS 和 Android 的 Apache Ripple 模拟器所需
Apache Ant 1.8.0+ – Required as a dependency for the Android build process
Apache Ant 1.8.0+ – 需要作为 Android 构建过程的依赖项
Oracle Java JDK 7 – Required as a dependency for the Android build process
Oracle Java JDK 7 – 需要作为 Android 构建过程的依赖项
Android SDK – Required as a dependency for the Android build process and Ripple
Android SDK – 需要作为 Android 构建过程和 Ripple 的依赖项
SQLLite for Windows Runtime – required to add SQL connectivity to Windows apps (for the WebSQL Polyfill plugin)
SQLLite for Windows Runtime – 需要将 SQL 连接添加到 Windows 应用程序(对于 WebSQL Polyfill 插件)
Apple iTunes – Required for deploying an app to an iOS device connected to your Windows PC
Apple iTunes – 将应用程序部署到连接到 Windows PC 的 iOS 设备时需要
回答by Mayur
I had same issue but finally i got success by doing this please go throw this image
Plase Run all the command in the PHONE TOOL COMMAND PROMPT
我遇到了同样的问题,但最终我通过这样做获得了成功,请扔这张图片Plase Run all the command in the PHONE TOOL COMMAND PROMPT
回答by Haroon Dilshad
Running the CMD as Administrator on Windows got me going and I think it only makes perfect sense because people don't really ever make an effort to install their stuff in a custom directory. So when you install node.js in Windows directory and then try to install PhoneGap on a Unelevated CMD it has a hard time setting the path variables.
在 Windows 上以管理员身份运行 CMD 让我继续前进,我认为这很有意义,因为人们并没有真正努力将他们的东西安装在自定义目录中。因此,当您在 Windows 目录中安装 node.js 然后尝试在 Unelevated CMD 上安装 PhoneGap 时,很难设置路径变量。