Custom plugin is not being called for Android platform
See original GitHub issueBug Report
Capacitor Version
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 3.3.2
@capacitor/core: 3.3.2
@capacitor/android: 3.3.2
@capacitor/electron: 3.3.2
@capacitor/ios: 3.3.2
Installed Dependencies:
@capacitor/cli 2.5.0
@capacitor/ios 2.5.0
@capacitor/core 2.5.0
@capacitor/android 2.5.0
@capacitor/electron not installed
[success] Android looking great! 👌
Found 1 Capacitor plugin for ios:
call-svc-plugin (0.0.1)
[success] iOS looking great! 👌
Platform(s)
Android
Current Behavior
I have created a CallSvcPlugin as described in creating-plugins that only has the echo functionality at this point. When I go to test the plugin, the iOS implementation is called when executed on an iOS device as expected. However the Android implementation is never called; instead the web implementation is being called. I am importing the plugin as follows…
import { Plugins } from '@capacitor/core';
const { CallSvcPlugin } = Plugins;
const reply1 = await CallSvcPlugin.echo({ value: 'You should not see this!' });
console.log(`[capacitor]: echo: ${reply1.value}`);
The plugin executed should just return “Hi from web!”, “Hi from iOS!”, or “Hi from Android!” depending on the platform used for test purposes.
Expected Behavior
Android custom plugin should be called. Device.getInfo() should return “android” when executed on Android device.
Code Reproduction
The code I’m testing is the same that was generated following creating-plugins
Other Technical Details
npm --version
output: 6.14.15
node --version
output: v14.17.6
pod --version
output (iOS issues only): 1.9.2
Additional Context
- I noticed that Device.getInfo().platform always returns “web” instead of expected “android” result
- I noticed the
npx cap doctor
command results above show “Found 1 Capacitor plugin for ios” but not for Android. Although I see the following fornpx cap sync
…
✔ Copying web assets from www to android/app/src/main/assets/public in 8.25ms
✔ Copying native bridge in 1.11ms
✔ Copying capacitor.config.json in 1.12ms
✔ copy in 22.77ms
✔ Updating Android plugins in 941.74μp
Found 1 Capacitor plugin for android:
call-svc-plugin (0.0.1)
✔ update android in 38.17ms
✔ Copying web assets from www to ios/App/public in 2.91ms
✔ Copying native bridge in 988.84μp
✔ Copying capacitor.config.json in 1.67ms
✔ copy in 9.65ms
✔ Updating iOS plugins in 2.31ms
Found 1 Capacitor plugin for ios:
call-svc-plugin (0.0.1)
✔ Updating iOS native dependencies with "pod install" (may take several minutes) in 4.44s
✔ update ios in 4.46s
✔ copy in 255.52μp
✔ update web in 4.48μp
Sync finished in 4.537s
-
I am calling EnableHttpsSelfSigned.enable(this.bridge); in my MainActivity.java as shown here
-
Output from Platform plugin… Platform.is.android: true Platform.is.capacitor: undefined Platform.is.chrome: true
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Disabling SSL checks is a security vulnerability that leads to app rejections just for being there (even if not used in production), so code to do that won’t be part of Capacitor.
I’ve created a Capacitor plugin that disables ssl checks on both iOS and Android. Notice that it’s a personal plugin (@jcesarmobile/ssl-skip), not official from Ionic Team.
For tooling that provides dev servers with self signed certificates such as quasar, they should handle the SSL errors themselves, as they did for Capacitor 2, they can install/uninstall the plugin or use a similar code directly put into users projects.
Hello. Why are you doing that? The problem is related to that, the bridge is not being injected and the platform is being detected as web, all android plugins will use the web version because of that.