1.0.0-beta.4
Android
Strangely, many Capacitor elements behave differently in release build.
For instance, with debug we don't have any issues, while release builds getting few crashes during testing all the time:

For instance, my friend's Galaxy S6 Android 6.0 (debloated, not stock) always crashing on launch with release version, but not with debug.
Another issue with navigator.geolocation described in #738
And we noticed that for some reason Plugins.App.openUrl stops to work in release version. It just doing nothing.
I'm sure there also other issues specific to the release build. It makes me feel there some kind of global issue with release build in Capacitor.
What can I do to help debug those issues?
@ArmorDarks
"And we noticed that for some reason Plugins.App.openUrl stops to work in release version. It just doing nothing."
Interesting since I have an issue opened regarding openUrl.
https://github.com/ionic-team/capacitor/issues/674
@solojuve1897 did you try it with debug or release build? Our issue happens only with release
In release also
Turned out that issues disappear if set in build.gradle minify to false.
I can only wonder why minification of the APK results in such issues.
Are you talking about minifyEnabled? or just minify?
Default value for minifyEnabled in the template is false (https://github.com/ionic-team/capacitor/blob/master/android-template/app/build.gradle#L15)
Cordova has always had problems with minification/proguard, but not really sure why. But I don't think this is related to the Cordova compat as your problem was with Capacitor Plugins, not with Cordova ones.
Yes, I meant minifyEnabled, sorry for the confusion.
We've set it to true because it was logical to do so, it just wasn't clear that it will lead to such issues.
But I don't think this is related to the Cordova compat as your problem was with Capacitor Plugins, not with Cordova ones.
yeap, we do not use any Cordova plugins. Only pure Capacitor, without any additions
It's probably related to minifyEnabled enabling proguard, which obfuscates the code and that can make the plugin execution code not work.
We can test this also setting minifyEnabled to true in debug mode too and then configure proguard to not obfuscate the classes related to plugin execution.
First, thank you Capacitor team for the amazing work you guys do!!
Secondly, I faced this issue last couple days, and the problem truly was minifyEnabled: true
setting that as false makes it all good.
Here my proguard-rules.pro configuration which seems to ensure that any plugin is preserved during minification (tested with plugins: byteowls-capacitor-oauth2, capacitor-fcm, capacitor-secure-storage-plugin and those of capacitor-android):
-keep,allowobfuscation @interface com.getcapacitor.NativePlugin,com.getcapacitor.PluginMethod
-keep @com.getcapacitor.NativePlugin class * { *; }
-keepclasseswithmembernames class * {
@com.getcapacitor.PluginMethod public *;
}
It could be put here and, as an embedded library proguard file, should be handled by any android/capacitor project.
Maybe it could be optimized but it does the job for me 😄!
@Rajarml How would you allow for a Cordova plugin in proguard-rules.pro? Would adding this work?
-keep class org.apache.cordova.** { *; }
-keep public class * extends org.apache.cordova.CordovaPlugin
@Rajarml How would you allow for a Cordova plugin in proguard-rules.pro? Would adding this work?
-keep class org.apache.cordova.** { *; } -keep public class * extends org.apache.cordova.CordovaPlugin
I would also like to know this. I moved my project from Cordova to Capacitor and it is something like 2.5MB bigger than the Cordova version. I would really like to be able to enable minifying.
I had a similar issue. I mixed the above solutions to make my application work with the minifyEnabled. I will test this solution heavily.
Probably public <fields>; is not needed here. Thanks to specifying only public methods, the rest of the code is obfuscated.
-keep public class * extends org.apache.cordova.* {
public <methods>;
public <fields>;
}
-keep @com.getcapacitor.NativePlugin public class * {
@com.getcapacitor.PluginMethod public <methods>;
}
Most helpful comment
Here my
proguard-rules.proconfiguration which seems to ensure that any plugin is preserved during minification (tested with plugins: byteowls-capacitor-oauth2, capacitor-fcm, capacitor-secure-storage-plugin and those of capacitor-android):It could be put here and, as an embedded library proguard file, should be handled by any android/capacitor project.
Maybe it could be optimized but it does the job for me 😄!