解决cordova deviceready has not fired after 5 seconds. 问题

57 阅读1分钟

问题描述

cordova框架在真机运行中可能会遇到deviceready has not fired after 5 seconds.Channel not fired: onPluginsReady的问题,将代码格式化显示后再运行会发现是在加载插件时,插件的exports 中的 .call报错 Invalid or unexpected token,不理解为什么会概率性的报这个错。 有些插件用的apply则没报过这个错。 且每次报错的插件还不一样,但问题都是同一个。

解决办法

不知道问题根源在哪,但测试发现只需要重载网页就能解决,所以找到platforms/android/platform_www/cordova.js,搜索deviceready has not fired after 5 seconds. image.png 在函数最后中添加 window.location.reload();即可。