Unable to find a Capacitor plugin to handle requestCode, trying Cordova plugins 101

Anyone know what would cause the error:

Unable to find a Capacitor plugin to handle requestCode, trying Cordova plugins 101

to appear? I’m developing my first custom plugin which presents a GooglePay screen on Android and when I click cancel on that dialog I see that message in the console. I think I must have the plugin registered correctly or else I would never see the GooglePay screen appear when I call it?

For Capacitor plugins to use request codes you have to put them in the plugin annotation, since you have provided your plugin code in Problem with custom Capacitor plugin (Android) getting control back from AutoResolveHelper.resolveTask, I can see you didn’t add the request code in the plugin annotation, so Capacitor can’t find a plugin that handles that code and goes to search on Cordova plugins and that’s what the message means.

Your plugin annotation should look like @CapacitorPlugin(name = "CapacitorPluginNativePayments", requestCodes = { 101 }).

Note that request codes are deprecated, I’m surprised google has not updated their own SDKs to use Activity Result API yet.

1 Like

Thank you. That got rid of my error. I have another error now but I should probably add a new separate post for that.