admin管理员组

文章数量:1264008

Today, I upgraded Cordova-CLI from version 3.5 to version 4.0. After this, I updated a project's platform support to the latest version of Android (since they get updated separately now).

Ever since then, I get this error showing up whenever I run cordova run android, I get the following error:

Uncaught TypeError: Cannot set property connection of # which has only a getter at file:///android_asset/www/cordova.js:512

As a result, a lot of events in the app don't get run, causing that app to not work.

Today, I upgraded Cordova-CLI from version 3.5 to version 4.0. After this, I updated a project's platform support to the latest version of Android (since they get updated separately now).

Ever since then, I get this error showing up whenever I run cordova run android, I get the following error:

Uncaught TypeError: Cannot set property connection of # which has only a getter at file:///android_asset/www/cordova.js:512

As a result, a lot of events in the app don't get run, causing that app to not work.

Share Improve this question asked Oct 20, 2014 at 12:32 Josh TumathJosh Tumath 1351 silver badge14 bronze badges 2
  • This could be a bug with the network-information plugin: issues.apache/jira/browse/CB-7848 In the meantime I followed John's suggestion. – th3hamm0r Commented Oct 30, 2014 at 13:57
  • 1 related issue is: issues.apache/jira/browse/CB-7868 – fr00t Commented Nov 6, 2014 at 15:12
Add a ment  | 

4 Answers 4

Reset to default 7

I started getting this after updating Cordova but only on very old Android phones. As a workaround I put a try/catch block around the contents of the function generating the error (clobber) in cordova.js :


    function clobber(obj, key, value) {
      try {
        exports.replaceHookForTesting(obj, key);
        obj[key] = value;
        // Getters can only be overridden by getters.
        if (obj[key] !== value) {
            utils.defineGetter(obj, key, function() {
                return value;
            });
        }
      }
      catch (e){
        console.error('clobber error '+e+', obj='+JSON.stringify(obj)+', key='+JSON.stringify(key)+', value='+JSON.stringify(value));
      }
    }

This obviously isn't the best fix but at least it lets the initialization plete and seems to not be affecting my app.

I met the same problem with Android cordova 3.6.4 got via CLI 4.1.2. I tried to merge two fixing of the issue:CB-7868. The first fixing can be saw with the link CB-7868,https://github./apache/cordova-js/pull/88. The second fixing is on the ment on CB-7868.

See *************

function clobber(obj, key, value) {

exports.replaceHookForTesting(obj, key);

obj[key] = value;
var needsProperty = false;
try { obj[key] = value; }
catch (e) { needsProperty = true; }
// Getters can only be overridden by getters.
if (obj[key] !== value) {
   if (needsProperty || obj[key] !== value) {
       utils.defineGetter(obj, key, function() { return value; }
 );

With those two fixing. There is no error reported on Android API14(4.0) and API15(4.0.3). But, I didn't try if the related plugins can work not. It means I don't know if the fixing is right or not.

Also, I got cordova 3.7.0 via CLI 4.1.2 for IOS platform. I can see the fixing, https://github./apache/cordova-js/pull/88, has been applied on 3.7.0 JS. But, the function ,clobber, still haven't above fixing. Also, there is no available 3.7.0 for Android cordova. It is still 3.6.4 for Android platform.

According to this post, the issue has been fixed.

By the way, I have to tell you I ran all mands in order to update a Cordova project for the Android platform but I can't get cordova.js updated to version 3.7.2.

I have the same problem. To solve it, I pared with an old version of "cordova.js" and removed lines 1187 to 1196 and 1316 to 1325. These lines are "else{}" portion of the function "replaceNavigator()". It works now for my app.

本文标签: