diff --git a/android/capacitor/proguard-rules.pro b/android/capacitor/proguard-rules.pro index 96db065b3..4fe4e3f2e 100644 --- a/android/capacitor/proguard-rules.pro +++ b/android/capacitor/proguard-rules.pro @@ -15,11 +15,18 @@ -keep public class * extends com.getcapacitor.Plugin { *; } +# The annotation types are read at runtime via reflection. If they are not kept, R8 full mode +# treats them as never instantiated and optimizes the annotation cached in PluginHandle to null, +# even with -keepattributes *Annotation*. +-keep @interface com.getcapacitor.annotation.** { *; } +-keep @interface com.getcapacitor.PluginMethod { *; } + # Rules for Capacitor v2 plugins and annotations # These are deprecated but can still be used with Capacitor for now -keep @com.getcapacitor.NativePlugin public class * { @com.getcapacitor.PluginMethod public ; } +-keep @interface com.getcapacitor.NativePlugin { *; } # Rules for Cordova plugins -keep public class * extends org.apache.cordova.* {