Cordova plugins with Capacitor - not working when build to signed APK / production mode

Hi,

I’m using the Insomnia plugin: https://ionicframework.com/docs/native/insomnia
It works fine when debugging my app, but when I build the signed APK, it stops working - giving me the following error:

java.lang.ClassNotFoundException: nl.xservices.plugins.Insomnia

I ran into the same issue with the App Preferences plugin, and had to actually user another native function to replace the plugin.

Do you know why this happens? That a plugin stops working with the signed APK version of the Build?
Any hint as what shall I do to avoid this kind of issue?

Thank you for your help.

I’m actually surprised by this issue, as I had the same with another plugin, and I just realized someone raised the exact same problem on github (which was then closed without solution):

Isn’t this an issue that someone else encountered? any solution?
Again, it works perfectly in debug mode, with non-signed APK… but as soon as you generate the signed APK for the android app store, plugins are gone…

I found the root cause: within android\app\ gradle.build, I set minifyEnabled to true (!)
The initial idea was to resolve the warning shown within the google play store, as to know:
This App Bundle contains Java/Kotlin code, which might be obfuscated. We recommend you upload a deobfuscation file to make your crashes and ANRs easier to analyze and debug

To resolve my issue, I currently set back minifyEnabled to false.

Nevertheless, this did not allow me to resolve the warning from the google play store - any tips as how to still get cordova plugins working while providing the needful to google?

Thx

1 Like