From 4119ab893ef39432dcf31012955b397074b1da7c Mon Sep 17 00:00:00 2001 From: Carl Poole Date: Fri, 3 Sep 2021 16:39:47 -0500 Subject: [PATCH 1/2] Rules suggested by #4780 --- android/capacitor/build.gradle | 1 + android/capacitor/proguard-rules.pro | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/android/capacitor/build.gradle b/android/capacitor/build.gradle index ae96db1fb..0b26aee1d 100644 --- a/android/capacitor/build.gradle +++ b/android/capacitor/build.gradle @@ -32,6 +32,7 @@ android { targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 30 versionCode 1 versionName "1.0" + consumerProguardFiles 'proguard-rules.pro' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/android/capacitor/proguard-rules.pro b/android/capacitor/proguard-rules.pro index f1b424510..b1fc63ec3 100644 --- a/android/capacitor/proguard-rules.pro +++ b/android/capacitor/proguard-rules.pro @@ -5,17 +5,21 @@ # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} +# Rules for Capacitor v3 plugins and annotations + -keep @com.getcapacitor.annotation.CapacitorPlugin public class * { + @com.getcapacitor.annotation.PermissionCallback ; + @com.getcapacitor.annotation.ActivityCallback ; + @com.getcapacitor.PluginMethod public ; + } -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable +# 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 ; +} -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile +# Rules for Cordova plugins +-keep public class * extends org.apache.cordova.* { + public ; + public ; +} \ No newline at end of file From 7e0fc5f264bdc82e7e1270c7d0c331745b883df5 Mon Sep 17 00:00:00 2001 From: Carl Poole Date: Fri, 3 Sep 2021 16:57:44 -0500 Subject: [PATCH 2/2] Permission annotation --- android/capacitor/proguard-rules.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/android/capacitor/proguard-rules.pro b/android/capacitor/proguard-rules.pro index b1fc63ec3..15c581dde 100644 --- a/android/capacitor/proguard-rules.pro +++ b/android/capacitor/proguard-rules.pro @@ -9,6 +9,7 @@ -keep @com.getcapacitor.annotation.CapacitorPlugin public class * { @com.getcapacitor.annotation.PermissionCallback ; @com.getcapacitor.annotation.ActivityCallback ; + @com.getcapacitor.annotation.Permission ; @com.getcapacitor.PluginMethod public ; }