chroder
chroder

Reputation: 4463

Windows Phone 7 and 8 with PhoneGap + Angular dies during bootstrapping

I have a PhoneGap app using AngularJS that works great on iOS and Android, but I'm having a problem getting it to work on Windows Phone 7 and 8.

The app starts fine and I see my index.html page (which in my case is just a loading screen). Source files are loaded and my pre-boot code is running fine.

Then it stops and nothing happens.

I've littered "console.log" messages throughout the code and I see it gets to the point of angular.bootstrap() and then dies. I'm not familiar enough with angular to know what to do next or how to debug this further to track down what the absolute problem code might be. Inside of bootstrap() begins the maze of DI calls so the code becomes much less linear.

I do see this error in the console but have no idea what it means or how to fix it:

An exception of type 'System.NotSupportedException' occurred in Microsoft.Phone.ni.dll and wasn't handled before a managed/native boundary

No other errors or any output is logged to the console. I tried delaying all of my bootstrap code by 10 seconds with a setTimeout and that error is always reported before angular.bootstrap() is called, so I don't know if it is even related.

Also worth noting that I've tried the app in IE on the desktop and it works fine there.

So my question is: How do I go about debugging this?

Upvotes: 7

Views: 2812

Answers (3)

wideblue
wideblue

Reputation: 57

I don't think this error is relevant because it is present even if you start Cordova/Phongap template app (I tried with Cordova 2.9.0). Visual Studio dosen't give any good explanation why app is not running, that's why I tried weinre and got the following massage on app reloade with angular-1.0.8

Error: Access is denied.
at hookedFunction (http://"my-weinre-ip":8080/target/target-script-min.js#ddtest:551:1)
at Anonymous function (x-wmapp0://www/components/angular/angular.js:9457:7)
at sendReq (x-wmapp0://www/components/angular/angular.js:9334:9)
at $http (x-wmapp0://www/components/angular/angular.js:9125:7)
at Anonymous function (x-wmapp0://www/components/angular/angular.js:9268:11)
at Anonymous function (x-wmapp0://www/components/angular/angular.js:7592:17)
at wrappedCallback (x-wmapp0://www/components/angular/angular.js:6996:15)
at wrappedCallback (x-wmapp0://www/components/angular/angular.js:6996:15)
at Anonymous function (x-wmapp0://www/components/angular/angular.js:7033:11)
at $eval (x-wmapp0://www/components/angular/angular.js:8219:9)

I reported it to angular here

EDIT

I managed to get a basic angular app running in phonegap WP7 (haven't tested it yet on WP8) by

  1. applying fix from github ( I can't post second link not enough reputation)

    @github/RobbinHabermehl/angular.js/commit/2645faad908529b5d33af960270755dd65a9aa78

  2. including jquery (2.0.3) above angular.js

  3. changing line of code in angular from

    var xhr = new XHR();

to

var xhr = new XMLHttpRequest(); 
  1. manually bootstrapping angular app after cordova deviceready event fired

I reported it in my original thread here

Upvotes: 1

MarmiK
MarmiK

Reputation: 5775

I agree with Jason, use Windows special/custom jQuery. And add unsafe=true

<script src="js/jquery-1.8.2-win8-1.0.min.js"></script>
<script type="text/javascript">
jQuery.isUnsafe = true;
</script>

The functionality of the Windows 8-patch had been included in jQuery 2.0. So can just use jQuery 2.0 in the same way, and it will work'.

So you can also use:

<script src="/lib/jquery-2.0.0.min.js"></script>
<script>
jQuery.isUnsafe = true;
</script>

Upvotes: 1

Jason Als
Jason Als

Reputation: 723

I am unsure of WP7/8 but if it follows Windows 8 pattern try adding JQuery 2.0 before angular.js

http://net.tutsplus.com/tutorials/javascript-ajax/building-windows-store-applications-with-jquery-2-0/

Upvotes: 2

Related Questions