Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap 2.9.0, Windows Phone 8, Durandal 2.0, XAP runtime issue

We've been trying to get our PhoneGap 2.9, Durandal 2.0 application working on Windows Phone 8. We've been able to follow the steps to deploy the application to the emulator and to the device via visual studio. However, we have a problem with the application when it is built in VS and then the finished .xap is deployed to the device using the Application Deployment tool. The splash screen loads but then a black screen is shown.

We have corrected the path to www as suggested in this blog post http://mikaelkoskinen.net/durandal-phonegap-windows-phone-8-tutorial/ which got the app working on the emulator but not on device.

We have also tried to build the xap using phonegap build since it now supports windows phone 8 in beta - http://phonegap.com/blog/2013/10/18/2013-10-18-phonegap-build-support-for-windows-phone-8/. This has returned a similar result.

We believe that the main.js and index.html files are being loaded fine but the issue is somehow with requirejs and durandal 2.

Is anyone else using this combination of tools (or more recent versions) successfully and if so do they know where we're going wrong.

like image 961
Laurence C Avatar asked Oct 22 '13 16:10

Laurence C


1 Answers

We have managed to solve the problem, so for anyone else who may experience the issue the following information may be useful.

1) Change the File.cs files as detailed in the blog post: http://mikaelkoskinen.net/durandal-phonegap-windows-phone-8-tutorial/

2) In addition to the above change, we found that it was also necessary to modify the options read from the parameter to the readResourceAsText method in File.cs as follows as PhoneGap doesn't require the other options, and seemingly doesn't pass them:

        string[] optStrings = getOptionStrings(options);
        string pathToResource = optStrings[0];
        //string encStr = optStrings[1];
        //int start = int.Parse(optStrings[2]);
        //int endMarker = int.Parse(optStrings[3]);
        string callbackId = optStrings[1];

3) For some reason the combination of Windows Phone, PhoneGap and Durandal is also very fussy over the folder structure of the application. Originally we were trying to use our own folder structure which made sense to us. (Ie. Not using the 'app' sub folder which is used in the Durandal starter kit example, and having main.js, viewmodels and views folders in the www root directory.) As the question states, this wasn't an issue on any other platform, or in debug mode, therefore we are unsure what the underlying issue is, but the folder structure should match exactly that in the Durandal starter kit for Windows Phone to work in release mode.

For additional information we have now also got this working in PhoneGap 3.1. (The same modifications as above apply, including modifying the File.cs plugin.)

We also tried PhoneGap build, which now supports PhoneGap 3.0, however the application crashes. This is due to the modifications required to File.cs not being used by build. Until this is fixed, it's not possible to use PhoneGap build with a Durandal app for Windows Phone 8.

like image 174
Brad Avatar answered Jan 30 '23 17:01

Brad