简体   繁体   English

使用Visual Studio 2015 New Emulator调试Cordova App(android)

[英]Debugging Cordova App (android) with Visual Studio 2015 New Emulator

I am not sure if this is me doing something stupid or just up against the bleeding edge.. I am developing a simple Cordova app but that is academic since I can repeat this issue with the standard 'Wizzard produced' default application. 我不确定这是我做的愚蠢的事情,还是只是为了应对最新趋势。.我正在开发一个简单的Cordova应用程序,但这是学术性的,因为我可以使用标准的“ Wizzard生产”默认应用程序重复此问题。

I had the app working and debugging fine with VS2013 using both Ripple and occasionally with a real device. 我使用Ripple并偶尔使用真实设备在VS2013上运行和调试应用程序都很好。 I don't have permanent access to the device so I thought Id try the new VS2015 CTP5 with emulator. 我没有对该设备的永久访问权,因此我想尝试使用带模拟器的新VS2015 CTP5。 So far so good. 到目前为止,一切都很好。 All builds ok and the app does get deployed to the emulator, and starts. 一切正常,应用程序确实部署到模拟器并启动。 However, VS is stuck in the 'deploying' process and never comes out. 但是,VS停留在“部署”过程中,永远不会出现。 To the extent that I have to 'ctrl-Break' out of it. 在某种程度上,我必须要“ ctrl-Break”。 and the debugger never starts.. The last few lines of the build output are: 并且调试器永远不会启动。构建输出的最后几行是:

2>  Built the following apk(s):
2>      C:\Users\Brett\Documents\VisualStudioCordova\Projects\mblapp\mblapp\bld\Debug\platforms\android\ant-build\CordovaApp-debug.apk
2>  Using apk: `C:\Users\Brett\Documents\VisualStudioCordova\Projects\mblapp\mblapp\bld\Debug\platforms`\android\ant-build\CordovaApp-debug.apk
2>  Installing app on device...
2>  Launching application...
2>  LAUNCH SUCCESS
2>  Command finished with error code 0: `C:\Users\Brett\Documents\VisualStudioCordova\Projects\mblapp\mblapp\bld\Debug\platforms`\android\cordova\run.bat --nobuild,--target=169.254.138.177:5555,--debug
2>  

So there is an error there but I really don't get what it means.. 所以那里有一个错误,但我真的不明白是什么意思。

Ok, So I went back to VS2013 but now the 2015 install has changed something and using Ripple it now breaks out of the code at unexpected places in the code.. not breakpoints.. and the javascript console says 'Paused at breakpoint' in its dropdown. 好的,所以我回到了VS2013,但是现在2015的安装已经改变了一些东西,现在使用Ripple,它在代码中的意外位置中断了代码..不是断点..并且javascript控制台在其末尾说了“ Pauseed at breakpoint”落下。 I cant access the 2015 Emulator directly, but out of interest I left the emulator running after 2015 was closed and CAN connect AND debug using VS 2013.. great.. but its not a great way to start debugging.. 我无法直接访问2015 Emulator,但是出于兴趣,我在2015年关闭后退出了模拟器,无法使用VS 2013进行连接和调试。..很棒。但是,这不是启动调试的好方法。

I really like the look of the new Emulator and it does seem to work great with 2013.. so does anyone out there know how to make VS2013 deploy to the new emulator? 我真的很喜欢新模拟器的外观,它看起来确实可以与2013搭配使用。.那么外面有人知道如何使VS2013部署到新模拟器上吗? .. I tried running it and did have some success. ..我尝试运行它,并取得了一些成功。 But I cant find where VS2015 has hidden its VHD file.. 但是我找不到VS2015隐藏其VHD文件的位置。

Or, does anyone know why VS2015 might not be deploying correctly.. Im happy to go with a solution that works.. Just that right now Im stuck not going forward, and its an uninstall 2015 and probable reinstall 2013 to go back... Many thanks. 还是有谁知道为什么VS2015可能无法正确部署。.我很高兴能找到一个可行的解决方案。.就在那一刻,我还坚持不前进,并且要卸载2015并可能重新安装2013才能返回...非常感谢。

OK.. Ive posted this as an answer because it does deal with part of it.. and I did struggle a bit so it might help someone else. 好..我已将此作为答案发布,因为它确实处理了其中的一部分..我确实有些挣扎,所以它可能会对其他人有所帮助。 Running the emulator from VS2013. 从VS2013运行模拟器。 You need to go to the folder 你需要去文件夹

C:\\Program Files (x86)\\Microsoft Visual Studio Emulator for Android\\1.0 C:\\ Program Files(x86)\\ Microsoft Visual Studio Emulator for Android \\ 1.0

where the emulator is installed. 安装模拟器的位置。 Having run it at least once from VS2015, it had created a file called vsemu.vhd and vsemu.sdcard.vhd. 从VS2015运行了至少一次之后,它创建了一个名为vsemu.vhd和vsemu.sdcard.vhd的文件。 Copy both these files to something similar in the same folder I used 'myemu'. 将这两个文件复制到我使用“ myemu”的同一文件夹中的类似文件。 Then to start the emulator I created a simple shortcut with the target property: 然后,要启动仿真器,我使用target属性创建了一个简单的快捷方式:

"C:\\Program Files (x86)\\Microsoft Visual Studio Emulator for Android\\1.0\\XDE.exe" /vhd bretts.vhd /video 1080x1920 “ C:\\ Program Files(x86)\\ Microsoft Visual Studio Emulator for Android \\ 1.0 \\ XDE.exe” / vhd bretts.vhd / video 1080x1920

this sets the resolution too.. You can find all the startup flags etc by using: 这也设置了分辨率。您可以使用以下命令找到所有启动标志等:

...XDE /? ... XDE /?

Im not sure yet, but I think it stored the various app shortcuts in the sdcard file.. although I wouldn't swear to it. 我还不确定,但是我认为它在sdcard文件中存储了各种应用程序快捷方式。尽管我不会发誓。 Ill repost if something changes there. 如果那里有什么变化,病重发。

Ok Debugging.. I started VS2013 and set the debug target as 'Device'. 好的调试。我启动了VS2013,并将调试目标设置为“设备”。 This worked fine.. so far. 到目前为止效果很好。

Id still love to know why 2015 is not deploying properly though, for now I'll just assume its the 'bleeding' part of the bleeding edge. 我仍然很想知道为什么2015年的部署不正确,现在我只是假设它是最前沿的“出血”部分。 Cheers 干杯

There is a known issue in Visual Studio 2015 CTP5 with Cordova projects deploying to the Visual Studio Emulator for Android. Visual Studio 2015 CTP5中存在一个已知问题,将Cordova项目部署到Android的Visual Studio模拟器中。 The issue will be resolved in the next release. 该问题将在下一版本中解决。

In the meantime, here are a few workarounds to try: 同时,您可以尝试以下几种解决方法:

  1. Search your machine for Microsoft.VisualStudio.MultiDeviceHybridApps.dll . 在计算机上搜索Microsoft.VisualStudio.MultiDeviceHybridApps.dll There will be two copies--one under "Program Files\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Emulator for Android\\" (the VS Emulator version of the dll) and one in another folder under "Program Files\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\" (the folder name varies, but it is always some random hash; this is the Cordova version of the dll). 将有两个副本-一个在“ Program Files \\ Microsoft Visual Studio 14.0 \\ Common7 \\ IDE \\ Extensions \\ Microsoft \\ Emulator for Android \\”(dll的VS Emulator版本)下,一个在另一个文件夹中的“ Program Files \\ Microsoft Visual Studio 14.0 \\ Common7 \\ IDE \\ Extensions \\”(文件夹名称有所不同,但始终是一些随机哈希;这是dll的Cordova版本)。 Close out of VS2015 and replace the Microsoft.VisualStudio.MultiDeviceHybridApps.dll in the Emulator for Android folder with the one in the Cordova folder (delete the Emulator one, copy the Cordova one, and paste it in the Emulator folder). 关闭VS2015,并使用Cordova文件夹中的一个替换Android for Emulator文件夹中的Microsoft.VisualStudio.MultiDeviceHybridApps.dll(删除一个Emulator,复制一个Cordova,并将其粘贴到Emulator文件夹中)。 Then go to "C:\\Users\\your username\\AppData\\Local\\Microsoft\\VisualStudio\\14.0\\Extensions" and delete the contents of this folder. 然后转到“ C:\\ Users \\您的用户名\\ AppData \\ Local \\ Microsoft \\ VisualStudio \\ 14.0 \\ Extensions”,然后删除该文件夹的内容。

  2. Create a new Visual C++ Native-Activity Application (File > New > Project, under Installed\\Templates\\Visual C++\\Cross Platform\\Native-Activity Application (Android)) and run it, then return to your Cordova project. 创建一个新的Visual C ++本机活动应用程序(“文件”>“新建”>“项目”,在“ Installed \\ Templates \\ Visual C ++ \\ Cross Platform \\ Native-Activity应用程序(Android)下”)并运行它,然后返回到您的Cordova项目。

  3. Reinstall CTP5 and the Visual Studio Emulator for Android and reinstall. 重新安装CTP5和Visual Studio Emulator for Android,然后重新安装。

Hope this helps! 希望这可以帮助!

Another workaround for webkit developers (Android and iOS), the Chrome remote debugger, check out here . 针对Webkit开发人员(Android和iOS)的另一种解决方法,Chrome远程调试器, 请点击此处

With this you can debug as you would do normally, this does work with the emulators of vs2015 ctp5! 有了它,您可以像平常一样调试,它可以与vs2015 ctp5的模拟器一起使用!

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

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