diff --git a/build-extras.gradle b/build-extras.gradle index 6b606e0ed..4b1e8cf97 100644 --- a/build-extras.gradle +++ b/build-extras.gradle @@ -2,6 +2,15 @@ android { packagingOptions { pickFirst 'META-INF/versions/9/OSGI-INF/MANIFEST.MF' } + buildTypes { + release { + //might cause ClassNotFoundException errors + //to fix those errors you need to either put @Keep on the class/feild or add a entry in progrud rules file + minifyEnabled true + shrinkResources true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } } configurations { diff --git a/config.xml b/config.xml index f97fd04fa..dc7650cf6 100644 --- a/config.xml +++ b/config.xml @@ -314,6 +314,11 @@ + + + + + diff --git a/proguard-rules.pro b/proguard-rules.pro new file mode 100644 index 000000000..db72d9a95 --- /dev/null +++ b/proguard-rules.pro @@ -0,0 +1,27 @@ +# Keep Cordova classes +-keep class org.apache.cordova.** { *; } + +# Cordova discovers plugins by class name from config.xml and instantiates them +# reflectively, and plugins can dispatch actions by method name through +# reflection too (e.g. Ftp.execute() uses +# getClass().getDeclaredMethod(action, JSONArray, CallbackContext)). +# Without keeping the members, R8 strips methods such as connect()/listDirectory() +# and those plugin calls fail at runtime with NoSuchMethodException. +-keep public class * extends org.apache.cordova.CordovaPlugin { *; } + +# WebView JS bridge methods are invoked by name from JavaScript. +-keepclassmembers class * { + @android.webkit.JavascriptInterface ; +} + +# cordova-plugin-buildinfo resolves the app's BuildConfig reflectively: +# Class.forName(packageName + ".BuildConfig") and c.getField(fieldName). +-keep class **.BuildConfig { *; } + +# maverick-synergy (SSH/SFTP) references java.lang.management from +# Utils.generateThreadDump(), which does not exist on Android. That method is +# never reached on Android, so ignore the missing Java SE classes. +-dontwarn java.lang.management.** + +# Keep Javascript Interface attributes +-keepattributes *Annotation*,EnclosingMethod,InnerClasses,Signature