apache / apache/cordova-android

Removing/re-adding Android platform results in "exec() call to unknown plugin" error at runtime

Open
#683 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.8k
Forks
1.6k
Avg merge
16h 18m
Merged PRs (30d)
11

Description

# Bug Report

## Problem

I had an issue reported against a plugin of mine (https://github.com/dpa99c/cordova-plugin-hello-c/issues/10) and from the description it seemed like `cordova-plugin-ionic-webview` was the cause, but after some testing I found this is a red herring and the issue can be recreated without that plugin in a simple test case, so it seems that it's directly related to `cordova-android`.

### What is expected to happen?
Removing/re-adding the Android platform does not cause an issue on subsequently building and running the app project.

### What does actually happen?
Removing/re-adding the Android platform causes an issue on subsequently building and running the app project.

## Information

[cordova-plugin-hello-c](https://github.com/dpa99c/cordova-plugin-hello-c) is a tutorial plugin that illustrates how to wrap a C/C++ library in a cross-platform Cordova plugin.

[cordova-plugin-hello-c-test](https://github.com/dpa99c/cordova-plugin-hello-c-test) is a simple test harness Cordova project to validate/demonstrate the above plugin.
It includes 2 plugins in its [`config.xml`](https://github.com/dpa99c/cordova-plugin-hello-c-test/blob/master/config.xml): `cordova-plugin-hello-c` and `cordova-plugin-whitelist`.

### Command or Code

To reproduce the issue:

git clone https://github.com/dpa99c/cordova-plugin-hello-c-test && cd cordova-plugin-hello-c-test
cordova platform add android@8.0.0
cordova run android

=> Observe plugin output appears

=> In `platforms/android/app/src/main/res/xml/config.xml` there is 1 `` element for `cordova-plugin-hello-c`:



Then remove/re-add Android platform:

cordova platform rm android --nosave && cordova platform add android --nosave
cordova run android

=> Observe plugin output does not appear

=> In `platforms/android/app/src/main/res/xml/config.xml` there is now 1 `` element for `cordova-plugin-whitelist`, i.e. none for `cordova-plugin-hello-c`:




=> The Android logcat indicates that on each call to the plugin, the plugin class could not be found by Cordova:

2019-02-26 17:47:49.429 11562-11648/io.cordova.hellocordova D/PluginManager: exec() call to unknown plugin: HelloCPlugin

Remove and re-add the plugin:

cordova plugin rm cordova-plugin-hello-c --nosave && cordova plugin add cordova-plugin-hello-c --nosave
cordova run android

=> Observe plugin is still not found:

2019-02-26 20:15:39.300 11093-11173/io.cordova.hellocordova D/PluginManager: exec() call to unknown plugin: HelloCPlugin

I can also produce the same result with `cordova-android@7.1.4` so it's not something that has been introduced in `cordova-android@8.0.0`

I'm not sure if this is related to https://github.com/apache/cordova-android/issues/636.

### Environment, Platform, Device

`cordova-android@7`, `cordova-android@8`

### Version information

`cordova@8.1.2`, `cordova-lib@8.1.1`, `cordova-android@8.0.0`
Windows 10 64-bit 1809
Android Studio 3.2.1

## Checklist

- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the commands in the issue using cordova-plugin-hello-c-test and cordova-android 7 or 8. Compare platforms/android/app/src/main/res/xml/config.xml before and after removing and re-adding Android, then use the Android logcat entry for HelloCPlugin as the runtime check. Done means the plugin feature is restored and the app no longer reports an unknown plugin.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
mobile, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.