Search code examples
cordovawindows-phone-8.1visual-studio-cordovaweinre

Is there a trick to get weinre to connect (WP8.1 via Tools for Apache Cordova CTP3)


so, I need console output via the console plugin and in order to get that I must have weinre running. The weinre instructions and tutorials are well written and extensive--I have every reason to believe I'm setup properly because from my test WP8.1 device I can use IE to navigate to my local weinre server and run the weinre red/green/blue demo. The local weinre server is running --boundHost 10.0.0.4 --debug and it accurately shows connection by the weinre demo via IE.

However, when putting <script>"http://10.0.0.4:8080/target/target-script-min.js#nokia"</script> into the template (BlankCordovaApp, the one that says "your application is ready") app's index.html (inside the head tag), building and running on Device, no attempt is made by the app to log onto the weinre server.

I'm assuming there must be a whitelist problem?

Clues are appreciated.

I would post my code but it literally is adding the script tag to the template's html... seemed excessive to me!


Solution

  • If you are targeting only WP8.1+ and are building a "packaged app" (you do not web pages access Cordova APIs), then try using the "Windows Phone (Universal)" target. This uses the updated "Windows" Cordova platform instead of WP8 and therefore has full access to the VS debugger. weinre is not required in this case and likely does not work due to the security model in place. weinre is only needed when using the WP8 Cordova Platform via the "Windows Phone 8" target.

    If you do need to use the WP8 platform, first validate that the phone can actually access the IP that you list above. A simple way to do this is to go to the browser on the phone and navigate to the URI above. It sounds like that did in fact work for you, so assuming it can access the URI and you are in fact using the WP8 Cordova platform, you could be running into a shortcoming with weinre. It is JavaScript based and as a result, there are occasions when a problem with your app code can cause it to cease functioning. Fortunately there is a fallback for console access. If you go into the bld/Debug/platforms/wp8 folder and open the solution found there you can run the app and you will see console output in the "Output" window.

    Edit: CTP3 does not currently support debugging Windows Phone (Universal) directly but going to the bld/Debug/platforms/windows folder and opening the solution there does. A soon to be released update will address this issue.