TypeError "Unable to establish connection of properties # <Navigator>" in the console when updating a project to the latest version of Cordova 4.0.0
Today I updated Cordova-CLI from version 3.5 to version 4.0. After that, I updated the support of the project platform to the latest version of Android (since now they are updated separately).
Since then I get this error, when I run cordova run android , I get the following error:
Uncaught TypeError: Unable to establish the connection of property #, which has only getter in the file: ///android_asset/www/cordova.js: 512
As a result, many events in the application do not fire, so the application does not work.
I met the same issue with Android cordova 3.6.4 obtained through CLI 4.1.2. I tried to combine two problems: CB-7868. The first fix can be seen with CB-7868, https://github.com/apache/cordova-js/pull/88 . The second correction is contained in the commentary on CB-7868.
Cm. *************
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 these two fixes. There is no error information in Android API14 (4.0) and API15 (4.0.3). But I did not try if the related plugins might work wrong. This means that I do not know if the correction is correct or not.
Also, I got cordova 3.7.0 through CLI 4.1.2 for IOS platform. I see that the fix, https://github.com/apache/cordova-js/pull/88 , was applied to 3.7.0 JS. But, the function, clobber, is still not above commit. In addition, there is no 3.7.0 for Android cordova. It still remains 3.6.4 for the Android platform.
I started getting this after updating Cordoba, 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 is obviously not the best fix, but at least it allows you to complete the initialization and does not seem to affect my application.
In accordance with this message, the problem is fixed.
By the way, I have to tell you that I executed all the commands to update the Cordova project for the Android platform, but I can not get cordova.js to version 3.7.2.
I have the same problem. To solve this problem, I compared the old version of "cordova.js" and deleted the lines 1187 to 1196 and 1316 to 1325. These lines are the "else {}" part of the "replaceNavigator ()" function. Now it works for my application.