Visual Studio Cordova - 您可能没有所需的环境或 OS 到 运行 这个项目

Visual Studio Cordova - You may not have the required environment or OS to run this project

我在 Visual Studio 2015 社区 - Apache Cordova 中遇到问题。我尝试在调试模式和发布模式下 运行 一个简单的应用程序并生成以下错误:

*2>  ANDROID_HOME=F:\AndroidSDK
2>  JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_55
2>C:\Temp\BlankCordovaApp1\BlankCordovaApp1\platforms\android\cordova\node_modules\q\q.js:126
2>throw e;
2>^
2>Error: Device communication timed out. Try unplugging & replugging the device.
2>at null._onTimeout (C:\Temp\Excluir\BlankCordovaApp1\BlankCordovaApp1\platforms\android\cordova\node_modules\q\q.js:1717:25)
2>at Timer.listOnTimeout (timers.js:110:15)
2>  Command finished with error code 1: cmd /s /c "C:\Temp\BlankCordovaApp1\BlankCordovaApp1\platforms\android\cordova\run.bat --nobuild --target=169.254.138.177:5555 --debug --buildConfig=C:\Temp\BlankCordovaApp1\BlankCordovaApp1\build.json"
2>  ERROR running one or more of the platforms: Error: cmd: Command failed with exit code 1
2>  You may not have the required environment or OS to run this project
2>  
2>C:\Temp\BlankCordovaApp1\BlankCordovaApp1\platforms\android\cordova\node_modules\q\q.js:126
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========*

我的 AndroidSDK 已完成(包含所有 API 和附加功能)。我的 AndroidSDK 的路径是正确的。已经尝试在 Android 的其他版本上 运行 并且错误是相同的。在Visual studio我已经清空了cordova缓存和删除了文件夹,新建了一个项目。已经重新安装了 Apache Cordova。仿真器正在使用 Hyper V 并且运行正常。我的 Windows 是 10 个 64 位。

如何解决这个问题?

真正的问题:超时。

我不知道是什么原因导致这个问题,但我有一个可能的解决方案。

文件夹:platforms\android\cordova\node_modules\q

文件:q.js

行: deferred.reject(新错误(消息|| "Timed out after " + ms + " ms")); }, 毫秒);

修改: deferred.reject(new Error(message || "Timed out after " + ms + " ms")); }, 40000);

不过我的情况是手动完成运行(快捷键:Ctrl+Break),如图: Visual Studio

另一种对我有帮助的方法是 运行 在终端中执行此命令:

cordova clean
cordova build
cordova run android

此后不再:

Error: Device communication timed out. Try unplugging & replugging the device