为什么 phonegap 无法 运行 wp8 模拟器?

Why is phonegap unable to run the wp8 emulator?

我使用的是 phonegap 3.7,我正在尝试通过以下方式启动模拟器:

phonegap run wp8

但如果失败:

Error: Invalid target device specified.

[..]

ERROR: Error code -2147024809 for command: C:\Program Files (x86)\Microsoft SDKs \Windows Phone\v8.0\Tools\Xap Deployment\XapDeployCmd.exe with args: /installlau nch,C:/Users/kitsunde/Development/pub_pure_app/src/platforms/wp8/Bin/debug/Cordo vaAppProj_Debug_AnyCPU.xap,/targetdevice:xd

Error: C:\Users\kitsunde\Development\pub_pure_app\src\platforms\wp8\cordova\run. bat: Command failed with exit code 2 at ChildProcess.whenDone (C:\Users\kitsunde\AppData\Roaming\npm\node_modules \phonegap\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.j s:135:23) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:766:16) at Process.ChildProcess._handle.onexit (child_process.js:833:5)

可能是什么原因造成的?

run wp8命令好像没有指定模拟器的目标机型。 您可以导航到 platforms/wp8 文件夹并打开解决方案文件(.sln 文件)。

然后您可以运行您的项目使用您想要的模拟器模型。

这里有一个 workaround 也可以解决这个问题,你可以看看这个。

Cordova/PhoneGap cannot add WP7/WP8/Windows platform

从 Cordova/PhoneGap 3.6 开始,如果您试图模拟 Windows Phone 8.1,则必须在 Cordova/PhoneGap 中使用 windows 平台比 wp8 平台。

phonegap platforms rm wp8
phonegap platforms add windows

The Apache Cordova 3.6 release has been inspired by the idea of Building universal Windows apps. It introduces a new unified ‘windows’ platform to build apps targeting Windows 8.0, Windows 8.1 and Windows Phone 8.1. Note, Windows Phone 8.0 still remains as a separate ‘wp8’ platform due to different implementation.

来自:http://akvelon.com/apache-cordova-adds-windows-8-1-and-windows-phone-8-1-universal-apps-support/

明白了吗?

  • Windows 8 > 使用 windows 平台
  • Windows 8.1 > 使用 windows 平台
  • Windows Phone 8 > 使用 wp8 平台
  • Windows Phone 8.1 > 使用 windows 平台

如果你真的只想模拟 Windows Phone 8,你可能需要安装 Windows Phone 8 sdk 如果你还没有。