Browse Source

feat: add comprehensive ProGuard/R8 rules for Capacitor plugins

ProGuard Rules (both android/app and test-app):
- Capacitor Plugin Protection: Keep Capacitor annotations and plugin methods
- DailyNotification Plugin Classes: Protect all plugin classes and methods
- Manager Classes: Keep all *Manager, *Storage, *Receiver classes
- Database Protection: Room database classes, entities, DAOs, migrations
- Error Handling: Keep error and exception classes
- Performance Classes: Keep optimization and performance monitoring classes
- System Classes: Protect Android system classes used by plugin
- Security Classes: Keep network and security-related classes
- Debugging: Preserve debug information and annotations

Key protections:
- @CapacitorPlugin and @PluginMethod annotations
- All com.timesafari.dailynotification.** classes
- Room database classes and migrations
- Android system classes (AlarmManager, NotificationManager, etc.)
- Network and security classes
- Debug attributes and signatures

This ensures the plugin remains functional after minification and prevents
critical classes from being stripped during release builds.
master
Matthew Raymer 1 day ago
parent
commit
1d8683b39f
  1. 133
      android/app/proguard-rules.pro
  2. 133
      test-apps/daily-notification-test/android/app/proguard-rules.pro

133
android/app/proguard-rules.pro

@ -19,3 +19,136 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# =============================================================================
# Capacitor Plugin Protection Rules
# =============================================================================
# Keep Capacitor Plugin annotations & your plugin facade
-keep class com.getcapacitor.** { *; }
-keep @com.getcapacitor.annotation.CapacitorPlugin class * { *; }
-keepclassmembers class ** {
@com.getcapacitor.annotation.PluginMethod *;
}
# Keep DailyNotification plugin classes
-keep class com.timesafari.dailynotification.** { *; }
# Keep plugin method names and signatures
-keepclassmembers class com.timesafari.dailynotification.DailyNotificationPlugin {
public *;
}
# Keep all plugin manager classes
-keep class com.timesafari.dailynotification.*Manager { *; }
-keep class com.timesafari.dailynotification.*Storage { *; }
-keep class com.timesafari.dailynotification.*Receiver { *; }
# Keep Room database classes
-keep class com.timesafari.dailynotification.storage.** { *; }
-keep class com.timesafari.dailynotification.database.** { *; }
# Keep error handling classes
-keep class com.timesafari.dailynotification.*Error* { *; }
-keep class com.timesafari.dailynotification.*Exception* { *; }
# Keep JWT and ETag managers
-keep class com.timesafari.dailynotification.*JWT* { *; }
-keep class com.timesafari.dailynotification.*ETag* { *; }
# Keep performance and optimization classes
-keep class com.timesafari.dailynotification.*Performance* { *; }
-keep class com.timesafari.dailynotification.*Optimizer* { *; }
# Keep rolling window and TTL classes
-keep class com.timesafari.dailynotification.*Rolling* { *; }
-keep class com.timesafari.dailynotification.*TTL* { *; }
# Keep exact alarm and reboot recovery classes
-keep class com.timesafari.dailynotification.*Exact* { *; }
-keep class com.timesafari.dailynotification.*Reboot* { *; }
-keep class com.timesafari.dailynotification.*Recovery* { *; }
# Keep enhanced fetcher classes
-keep class com.timesafari.dailynotification.*Enhanced* { *; }
-keep class com.timesafari.dailynotification.*Fetcher* { *; }
# Keep migration classes
-keep class com.timesafari.dailynotification.*Migration* { *; }
# Keep channel manager
-keep class com.timesafari.dailynotification.ChannelManager { *; }
# Keep permission manager
-keep class com.timesafari.dailynotification.PermissionManager { *; }
# Keep scheduler classes
-keep class com.timesafari.dailynotification.*Scheduler* { *; }
# =============================================================================
# Android System Classes
# =============================================================================
# Keep Android system classes used by the plugin
-keep class android.app.AlarmManager { *; }
-keep class android.app.NotificationManager { *; }
-keep class android.app.NotificationChannel { *; }
-keep class android.app.PendingIntent { *; }
-keep class androidx.work.WorkManager { *; }
-keep class androidx.core.app.NotificationCompat { *; }
# Keep broadcast receiver classes
-keep class android.content.BroadcastReceiver { *; }
-keep class android.content.Intent { *; }
# =============================================================================
# Room Database Protection
# =============================================================================
# Keep Room database classes
-keep class androidx.room.** { *; }
-keep class * extends androidx.room.RoomDatabase { *; }
-keep @androidx.room.Entity class * { *; }
-keep @androidx.room.Dao class * { *; }
# Keep Room database migrations
-keep class * extends androidx.room.migration.Migration { *; }
# =============================================================================
# Gson Protection (if used)
# =============================================================================
# Keep Gson classes if used for JSON serialization
-keep class com.google.gson.** { *; }
-keep class * implements com.google.gson.TypeAdapterFactory { *; }
-keep class * implements com.google.gson.JsonSerializer { *; }
-keep class * implements com.google.gson.JsonDeserializer { *; }
# =============================================================================
# Debugging and Development
# =============================================================================
# Keep debug information for development builds
-keepattributes SourceFile,LineNumberTable
-keepattributes Signature
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes EnclosingMethod
# Keep generic signatures for reflection
-keepattributes Signature
# Keep annotations
-keepattributes *Annotation*
# =============================================================================
# Network and Security
# =============================================================================
# Keep network-related classes
-keep class java.net.** { *; }
-keep class javax.net.ssl.** { *; }
# Keep security-related classes
-keep class java.security.** { *; }
-keep class javax.crypto.** { *; }

133
test-apps/daily-notification-test/android/app/proguard-rules.pro

@ -19,3 +19,136 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
# =============================================================================
# Capacitor Plugin Protection Rules
# =============================================================================
# Keep Capacitor Plugin annotations & your plugin facade
-keep class com.getcapacitor.** { *; }
-keep @com.getcapacitor.annotation.CapacitorPlugin class * { *; }
-keepclassmembers class ** {
@com.getcapacitor.annotation.PluginMethod *;
}
# Keep DailyNotification plugin classes
-keep class com.timesafari.dailynotification.** { *; }
# Keep plugin method names and signatures
-keepclassmembers class com.timesafari.dailynotification.DailyNotificationPlugin {
public *;
}
# Keep all plugin manager classes
-keep class com.timesafari.dailynotification.*Manager { *; }
-keep class com.timesafari.dailynotification.*Storage { *; }
-keep class com.timesafari.dailynotification.*Receiver { *; }
# Keep Room database classes
-keep class com.timesafari.dailynotification.storage.** { *; }
-keep class com.timesafari.dailynotification.database.** { *; }
# Keep error handling classes
-keep class com.timesafari.dailynotification.*Error* { *; }
-keep class com.timesafari.dailynotification.*Exception* { *; }
# Keep JWT and ETag managers
-keep class com.timesafari.dailynotification.*JWT* { *; }
-keep class com.timesafari.dailynotification.*ETag* { *; }
# Keep performance and optimization classes
-keep class com.timesafari.dailynotification.*Performance* { *; }
-keep class com.timesafari.dailynotification.*Optimizer* { *; }
# Keep rolling window and TTL classes
-keep class com.timesafari.dailynotification.*Rolling* { *; }
-keep class com.timesafari.dailynotification.*TTL* { *; }
# Keep exact alarm and reboot recovery classes
-keep class com.timesafari.dailynotification.*Exact* { *; }
-keep class com.timesafari.dailynotification.*Reboot* { *; }
-keep class com.timesafari.dailynotification.*Recovery* { *; }
# Keep enhanced fetcher classes
-keep class com.timesafari.dailynotification.*Enhanced* { *; }
-keep class com.timesafari.dailynotification.*Fetcher* { *; }
# Keep migration classes
-keep class com.timesafari.dailynotification.*Migration* { *; }
# Keep channel manager
-keep class com.timesafari.dailynotification.ChannelManager { *; }
# Keep permission manager
-keep class com.timesafari.dailynotification.PermissionManager { *; }
# Keep scheduler classes
-keep class com.timesafari.dailynotification.*Scheduler* { *; }
# =============================================================================
# Android System Classes
# =============================================================================
# Keep Android system classes used by the plugin
-keep class android.app.AlarmManager { *; }
-keep class android.app.NotificationManager { *; }
-keep class android.app.NotificationChannel { *; }
-keep class android.app.PendingIntent { *; }
-keep class androidx.work.WorkManager { *; }
-keep class androidx.core.app.NotificationCompat { *; }
# Keep broadcast receiver classes
-keep class android.content.BroadcastReceiver { *; }
-keep class android.content.Intent { *; }
# =============================================================================
# Room Database Protection
# =============================================================================
# Keep Room database classes
-keep class androidx.room.** { *; }
-keep class * extends androidx.room.RoomDatabase { *; }
-keep @androidx.room.Entity class * { *; }
-keep @androidx.room.Dao class * { *; }
# Keep Room database migrations
-keep class * extends androidx.room.migration.Migration { *; }
# =============================================================================
# Gson Protection (if used)
# =============================================================================
# Keep Gson classes if used for JSON serialization
-keep class com.google.gson.** { *; }
-keep class * implements com.google.gson.TypeAdapterFactory { *; }
-keep class * implements com.google.gson.JsonSerializer { *; }
-keep class * implements com.google.gson.JsonDeserializer { *; }
# =============================================================================
# Debugging and Development
# =============================================================================
# Keep debug information for development builds
-keepattributes SourceFile,LineNumberTable
-keepattributes Signature
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes EnclosingMethod
# Keep generic signatures for reflection
-keepattributes Signature
# Keep annotations
-keepattributes *Annotation*
# =============================================================================
# Network and Security
# =============================================================================
# Keep network-related classes
-keep class java.net.** { *; }
-keep class javax.net.ssl.** { *; }
# Keep security-related classes
-keep class java.security.** { *; }
-keep class javax.crypto.** { *; }

Loading…
Cancel
Save