Open igorsantos07 opened 11 months ago
I just had this bug too. I updated the plugin using cordova plugin remove cordova-plugin-device --force
and then cordova plugin add cordova-plugin-device
and I got this bug.
It worked again after I did cordova platform remove android
, cordova plugin remove cordova-plugin-device
, cordova plugin add cordova-plugin-device
, and then cordova platform add android
, but it was a bit of a hassle.
I've confirmed that the repro steps reliably reproduces the issue. Seems weird it would only affect this plugin though.
There are 3 main paths (relative to the root of the cordova project) that cordova tracks installed plugins:
The first 2 is cleaned up as expected. The third one instructs the cordova runtime about what is "installed" and that isn't being cleaned up, so as far as the app runtime is concerned the plugin does exist. The 4th bonus one is the plugin JS code which is also not cleaned up.
The native java code however is cleaned up as expected.
Some additional information I've found when testing other plugins and will explain:
We also removed other plugins and didn't had this kind of trouble.
So first this bug does occur on all plugins it seems like. However only the last plugin removed is left in a "broken" state.
So what I did was did the steps to reproduce the issue on the device plugin, and had my environment in a broken state with the device plugin.
I repeated the steps for the file plugin. When I removed the file plugin, it ended up "correcting" the state with the device plugin, but the file plugin state was broken (all the file plugin JS modules and module entries were lingered).
Repeating the steps for the device plugin again, fixed the broken state of the file plugin, but the broken state of the device plugin returned.
This bug is probably more suitable for cordova-lib
so I'll move it.
The bug is reproducible on the iOS platform as well, not just on Android.
Bug Report
Problem
If an application has this plugin installed and, for some reason, it's not needed anymore and removed,
ondeviceready
won't fire anymore. This seems to be caused by some leftover code... That's probably why the previous reporter mentioned the usual shenanigans of add/remove platform/plugins solved it.What is expected to happen?
The event should fire as usual, since it's seemingly unrelated to this plugin.
What does actually happen?
ondeviceready
never gets fired:Logcat displays the following (easier to find if you filter logcat by the package name):
Command or Code
Environment, Platform, Device
Version information
Nothing besides what was described above seems relevant.
Checklist