Cap Plugins - Route Android platform calls to Web code

Hi! I’m trying to see if there’s a way to only have an iOS implementation of a capacitor plugin I’m writing. I understand I can do the not-implemented call responses on Android, but would be helped greatly if there was a way to instead just let the android platform calls route to the web code.

iOS → iOS
Android → Web
Web → Web

Is this possible?

Yes, it’s possible, just remove all the Android java code from the plugin (or the whole android folder), it should fallback to using the web code automatically.

@julio-ionic When I delete /android from the plugin codebase, I am unable to build the main ionic app that the plugin is installed to (fails on sync). I tried fooling around with un-registering the plugin on android side only but it seemed like I was unable to touch that process.

I then tried removing all plugin java code, such that there were two blank java files at src/main/java/com/etc/etc/pluginname/. When I run this, the app tries to execute the java and just continues on, not touching web code. Is there anything I’m missing?

I’ve also tried removing the “android” property in the “capacitor” property in the plugin package.json such that it looked like this:

  "capacitor": {
    "ios": {
      "src": "ios"

But then nothing runs at all, web or otherwise. Any further ideas?

Ah, yeah, you also need to remove the android entry from capacitor object in package.json

You also need something like this in the registerPlugin call in index.ts file

1 Like

This did the trick! I did both of these steps independent of each other but never combined them. Thanks for the help.