1

I am currently developing an application for mobile phones using angularJS and cordova 3.2.

Some of my players report, that the application is not starting on their devices. This devices are listed below.

  • optimus p880 (Android Version 4.0.3)
  • Lifetab von Medion (Adroid Version 4.0.3)
  • Sony Ericsson Xperia mini pro ( Android 4.0.4)

So it seems somehow connected to that Android Version 4.0.3/4.

Not starting means, that the cordova application is starting, but that angularjs crashes before it is initiated, because all the elements where an ng-cloak class is attached (which in my case is set for the complete root window) remain hidden. So the user does not see anything.

The problem is, that I don't have any of this devices to test it, but one player did send me the logs of his device, saying

Uncaught SyntaxError: Unexpected strict mode reserved word

With the line number and the file name I could determine, that the problem is caused by the code below (its from the angular.js v1.2.16 file in line 3878). The problem seems to apply in the statement throw err;

(#3878)
function createInternalInjector(cache, factory) {

  function getService(serviceName) {
    if (cache.hasOwnProperty(serviceName)) {
      if (cache[serviceName] === INSTANTIATING) {
        throw $injectorMinErr('cdep', 'Circular dependency found: {0}', path.join(' <- '));
      }
      return cache[serviceName];
    } else {
      try {
        path.unshift(serviceName);
        cache[serviceName] = INSTANTIATING;
        return cache[serviceName] = factory(serviceName);
      } catch (err) {
        if (cache[serviceName] === INSTANTIATING) {
          delete cache[serviceName];
        }
        throw err; /*** THE ERROR APPLIES HERE! **/
      } finally {
        path.shift();
      }
    }
  }

I cannot really say, what happens here. The applications works fine on other devices and other android versions.

Has anyone of you an idea how I could fix that issue for the players?

2
  • No ideas? Its really blocking for me, and I would like to get a solution! Commented Jun 25, 2014 at 12:48
  • What are the names of your services? I got this error once when I tried to name a function with a (future) reserved word. You probably have the same. Do not remove the 'use strict' directives just because of this. Commented Sep 12, 2014 at 19:21

1 Answer 1

1

For us this is being thrown only on Android 4.0.4 Galaxy S2 Stock Browser (and app web view) and can be resolved by removing 'use strict;' from our app.js.

I tracked down the offending code by console.logging the value fn.toString().substring(0,150) in the angular.js annotate function, and inspecting the logs in Weinre after hitting about:debug in the Stock Browser, which enables the console on the Stock Browser. Might help you track the problematic line in your own code. It might be that not everyone gets the error at the annotate() step. You should see the line in the console log.

Galaxy S3 with the exact same OS and browser is fine... go figure.

Still looking for a way to have the 'use strict'; there and not get the error. Wrapping the whole thing in an IIFE didn't do the trick and still getting the error in that case.

Sign up to request clarification or add additional context in comments.

1 Comment

I have not found a solution so far, I just removed 'use strict' in all my files...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.