question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues in release build when minifyEnabled is set to true

See original GitHub issue

Capacitor version

1.0.0-beta.4

Platform

Android

Issue

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:

image

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?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:27 (10 by maintainers)

github_iconTop GitHub Comments

14reactions
Rajarmlcommented, Mar 11, 2020

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 😄!

6reactions
Zapominaczcommented, Jun 24, 2021

Hi @hschindler

Native api in capacitor has changed. For Capacitor v3 (ionic and angular version does not matter) with minifyEnabled true we should write in proguard-rules.pro:

-keep @com.getcapacitor.annotation.CapacitorPlugin public class * {
    @com.getcapacitor.PluginMethod public <methods>;
}

EDIT: Added directives for permissions and activities result:

-keep @com.getcapacitor.annotation.CapacitorPlugin public class * {
    @com.getcapacitor.annotation.PermissionCallback <methods>;
    @com.getcapacitor.annotation.ActivityCallback <methods>;
    @com.getcapacitor.PluginMethod public <methods>;
}

If older (v2) plugins are present, this also should be added:

-keep @com.getcapacitor.NativePlugin public class * {
    @com.getcapacitor.PluginMethod public <methods>;
}

And, if Cordova plugins are still present:

-keep public class * extends org.apache.cordova.* {
    public <methods>;
    public <fields>;
}

Tested on fresh project created with ionic cli with Capacitor v3, angular v12 and ionic v5

Read more comments on GitHub >

github_iconTop Results From Across the Web

minifyEnabled causing app to crash on release mode
If the crash of the app happens, then you need to configure ProGuard. Concrete configuration depends on your project and its dependencies. Every...
Read more >
App crashes with minifyEnabled true [37114347] - Issue Tracker
Apologies, you'll need to edit the gradle script to set minifyEnabled to true and make sure to build the release variant. (I just...
Read more >
Importance of Proguard for the Android platform and its ...
Sometimes the app crashes in release build even when the app is running fine in debug build. It might be an issue with...
Read more >
Azure Spatial Anchors Android NDK lib fails to load when ...
To reproduce change "minifyEnabled false" to "minifyEnabled true" or ... In Android Studio select build variant release, configure signing.
Read more >
[Help]Problem with minifyEnabled when set true : r/androiddev
Since I improved my application, whenever I enable the minifyEnabled on the gradle settings, my application crashes on start. I made several changes....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found