Uncaught TypeError: Cannot read property 'call' of undefined, not custom plugin related.
See original GitHub issueDescription of the problem:
Affected platform
- Android 5.0.2
- iOS
- electron
- web
OS of the development machine
- Windows
- macOS
- linux
Other information: Run on emulator, the same app run on Android 6+ works fine.
Capacitor version: 1.1.1
node version: 8.13.0
npm version: 6.4.1
Steps to reproduce:
Create a project for android,
run it on the Android 5.0 (device or emulator),
use the addListener
on App
plugin
Inspect the WebView and notice the error in console: Uncaught TypeError: Cannot read property 'call' of undefined
Try to call following from the dev tools console:
Capacitor.Plugins.App.addListener('appStateChange', function handler() {console.log("App State Changed");})
You will notice the TypeError: Cannot read property 'call' of undefined
error. debug and it will point to the
} catch (e) {
orgConsole.error.call(win.console, e); // this line
}
further debug will show that orgConsole
is empty! and was attemptet to populate with a line starting Object.keys(win.console)
Attempt to console log the Object.keys(window.console)
will show taht only memory
key is lsited (where is log
, error
?) It seems that on the WebView available for Android 5.0 the console is not iterable.
The same call on the dev tools on the Android 6+ lists all of available console methods. (e.g. Android 8 - 24 items listed)
Possible solution could be to create a static list of console props
const consoleLevels = [
'debug',
'error',
'info',
'log',
'trace',
'warn',
// anything else needed
];
// then
consoleLevels.forEach(function(level){
// rest of the code
});
Link to sample project: N\A
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
Hi @jcesarmobile - any idea when next release of capacitor-android will be?
We need to run our app on a Clover Flex device, which runs Android 5.1.
next release of capacitor-android won’t have this console overwrite, so won’t be a problem