diff --git a/android/capacitor/src/main/java/com/getcapacitor/Plugin.java b/android/capacitor/src/main/java/com/getcapacitor/Plugin.java index cedd7c7b9..3caeaed09 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/Plugin.java +++ b/android/capacitor/src/main/java/com/getcapacitor/Plugin.java @@ -300,7 +300,7 @@ public void pluginRequestPermission(String permission, int requestCode) { */ private void addEventListener(String eventName, PluginCall call) { List listeners = eventListeners.get(eventName); - if (listeners == null) { + if (listeners == null || listeners.isEmpty()) { listeners = new ArrayList(); eventListeners.put(eventName, listeners); @@ -335,7 +335,7 @@ private void removeEventListener(String eventName, PluginCall call) { protected void notifyListeners(String eventName, JSObject data, boolean retainUntilConsumed) { Log.v(getLogTag(), "Notifying listeners for event " + eventName); List listeners = eventListeners.get(eventName); - if (listeners == null) { + if (listeners == null || listeners.isEmpty()) { Log.d(getLogTag(), "No listeners found for event " + eventName); if (retainUntilConsumed) { retainedEventArguments.put(eventName, data); diff --git a/cli/src/cordova.ts b/cli/src/cordova.ts index 9698c5202..33eba0588 100644 --- a/cli/src/cordova.ts +++ b/cli/src/cordova.ts @@ -414,7 +414,9 @@ ${applicationXMLEntries.join('\n')} ${rootXMLEntries.join('\n')} `; content = content.replace(new RegExp(('$PACKAGE_NAME').replace('$', '\\$&'), 'g'), config.app.appId); - await writeFileAsync(manifestPath, content); + if (existsSync(manifestPath)) { + await writeFileAsync(manifestPath, content); + } } function getPathParts(path: string) {