Skip to content

ondeviceready won't fire because plugin does not cleanup after itself properly when removed(?) #927

@igorsantos07

Description

@igorsantos07

Bug Report

Originally reported at apache/cordova-plugin-device#125

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:
image

Logcat displays the following (easier to find if you filter logcat by the package name):

2023-10-14 22:59:13.783 29167-29267 PluginManager           io.cordova.hellocordova              D  exec() call to unknown plugin: Device
2023-10-14 22:59:13.834 29167-29167 chromium                io.cordova.hellocordova              I  [INFO:CONSOLE(80)] "[ERROR] Error initializing cordova-plugin-device: Class not found", source: https://localhost/plugins/cordova-plugin-device/www/device.js (80)
2023-10-14 22:59:18.645 29167-29167 chromium                io.cordova.hellocordova              I  [INFO:CONSOLE(1237)] "deviceready has not fired after 5 seconds.", source: https://localhost/cordova.js (1237)
2023-10-14 22:59:18.645 29167-29167 chromium                io.cordova.hellocordova              I  [INFO:CONSOLE(1230)] "Channel not fired: onCordovaInfoReady", source: https://localhost/cordova.js (1230)

Command or Code

$ cordova create sample-reproduction
$ cd sample-reproduction
$ cordova platform add android
$ cordova plugin add cordova-plugin-device
$ cordova plugin rm cordova-plugin-device
$ cordova run android

Environment, Platform, Device

  • cordova-android: 12.0.0 and 12.0.1
  • plugin: 2.1.0 (as in clean install below), and also our actual project had it installed on 1.1.4, upgraded to 2.1.0, then realized it's not used and thus, got removed. We also removed other plugins and didn't had this kind of trouble.
  • device: Android emulator, API 30

Version information

Nothing besides what was described above seems relevant.

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions