From 60176c61db1d179ad3bf4a2971ba22ffd98622b2 Mon Sep 17 00:00:00 2001 From: subranil Date: Wed, 15 Jul 2020 14:34:10 +0530 Subject: [PATCH 1/6] Issue #SB-19779 feat: added buildScript and proguard rules --- build.sh | 2 + buildConfig/build-extras.gradle | 2 + proguard-custom.txt | 168 ++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 100644 proguard-custom.txt diff --git a/build.sh b/build.sh index 73f4d6bf7..0173a15be 100755 --- a/build.sh +++ b/build.sh @@ -44,6 +44,8 @@ rm -rf platforms #need to inspect on webpack dependdencies at the earliest NODE_OPTIONS=--max-old-space-size=4096 ionic cordova platforms add android@8.1.0 +cp "proguard-custom.txt" "www" + NODE_OPTIONS=--max-old-space-size=4096 ionic cordova build android --prod --release --buildConfig ./buildConfig/build.json npm run ionic-build diff --git a/buildConfig/build-extras.gradle b/buildConfig/build-extras.gradle index 934dddcc9..d1efa1ab8 100644 --- a/buildConfig/build-extras.gradle +++ b/buildConfig/build-extras.gradle @@ -90,6 +90,8 @@ android { release { buildConfigField "boolean", "USE_CRASHLYTICS", "true" ext.enableCrashlytics = true + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'src/main/assets/www/proguard-custom.txt' } debug{ buildConfigField "boolean", "USE_CRASHLYTICS", "false" diff --git a/proguard-custom.txt b/proguard-custom.txt new file mode 100644 index 000000000..3bf020ee6 --- /dev/null +++ b/proguard-custom.txt @@ -0,0 +1,168 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: +#-dontshrink +#-dontoptimize +#-dontobfuscate + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class android.webkit.WebView { +# public *; +#} + +#-injars bin/classes +#-injars libs +#-outjars bin/classes-processed.jar + +# Using Google's License Verification Library +-keep class com.android.vending.licensing.ILicensingService + +# Specifies to write out some more information during processing. +# If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message. +-verbose + +# Annotations are represented by attributes that have no direct effect on the execution of the code. +-keepattributes *Annotation* + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keepattributes InnerClasses +-keep class **.R +-keep class **.R$* { + ; +} + +# These options let obfuscated applications or libraries produce stack traces that can still be deciphered later on +-renamesourcefileattribute SourceFile +-keepattributes SourceFile,LineNumberTable + +# Enable proguard with Cordova +-keep class org.apache.cordova.** { *; } +-keep public class * extends org.apache.cordova.CordovaPlugin + +-keep class com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader { java.lang.ClassLoader sClassLoader; } + +-keep class org.apache.cordova.CordovaBridge { org.apache.cordova.PluginManager pluginManager; } +-keep class org.apache.cordova.CordovaInterfaceImpl { org.apache.cordova.PluginManager pluginManager; } +-keep class org.apache.cordova.CordovaResourceApi { org.apache.cordova.PluginManager pluginManager; } +-keep class org.apache.cordova.CordovaWebViewImpl { org.apache.cordova.PluginManager pluginManager; } +-keep class org.apache.cordova.ResumeCallback { org.apache.cordova.PluginManager pluginManager; } +-keep class org.apache.cordova.engine.SystemWebViewEngine { org.apache.cordova.PluginManager pluginManager; } + +-dontnote org.apache.harmony.xnet.provider.jsse.NativeCrypto +-dontnote sun.misc.Unsafe + +-keep class com.worklight.androidgap.push.** { *; } +-keep class com.worklight.wlclient.push.** { *; } + +# Enable proguard with Google libs +-keep class com.google.** { *; } +-dontwarn com.google.common.** +-dontwarn com.google.ads.** +-dontwarn com.google.android.gms.** + +# apache.http +-optimizations !class/merging/vertical*,!class/merging/horizontal*,!code/simplification/arithmetic,!field/*,!code/allocation/variable + +-keep class net.sqlcipher.** { *; } +-dontwarn net.sqlcipher.** + +-keep class org.codehaus.** { *; } +-keepattributes *Annotation*,EnclosingMethod + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Remove debug logs in release build +-assumenosideeffects class android.util.Log { + public static *** d(...); +} + +# These classes contain references to external jars which are not included in the default MobileFirst project. +-dontwarn com.worklight.common.internal.WLTrusteerInternal* +-dontwarn com.worklight.jsonstore.** +-dontwarn org.codehaus.jackson.map.ext.* +-dontwarn com.worklight.androidgap.push.GCMIntentService +-dontwarn com.worklight.androidgap.plugin.WLInitializationPlugin + +-dontwarn android.support.v4.** +-dontwarn android.net.SSLCertificateSocketFactory +-dontwarn android.net.http.* + +# These clases contain references to cordova webView +-keep class com.ionicframework.cordova.webview.** {*; } +-keep class com.ionicframework.cordova.webview.* + +-dontwarn java.awt.**,javax.swing.** +-dontwarn org.mozilla.javascript.tools.** +-dontwarn com.nimbusds.jose.crypto.** +-dontwarn com.nimbusds.jose.jwk.ECKey.** +-dontwarn com.nimbusds.jose.** +-dontwarn com.nimbusds.jwt.** +-dontwarn okhttp3.** +-dontwarn okio.** +-dontwarn javax.annotation.** +-dontwarn org.conscrypt.** +#Keep ADAL classes +-keep class com.microsoft.aad.adal.** { *; } +-keep class com.microsoft.identity.common.** { *; } +#Keep Gson for ADAL https://github.com/google/gson/blob/master/examples/android-proguard-example/proguard.cfg +-keepattributes Signature +-keepattributes *Annotation* +-dontwarn sun.misc.** +-keep class com.google.gson.examples.android.model.** { *; } +-keep class * implements com.google.gson.** {*;} +-dontwarn org.bouncycastle.** +-keepnames class com.fasterxml.jackson.databind.** { *; } +-dontwarn com.fasterxml.jackson.databind.* +-keepattributes InnerClasses +-keep class org.bouncycastle.** { *; } +-keepnames class org.bouncycastle.* { *; } +-dontwarn org.bouncycastle.* +-keep class io.jsonwebtoken.** { *; } +-keepnames class io.jsonwebtoken.* { *; } +-keepnames interface io.jsonwebtoken.* { *; } +-dontwarn javax.xml.bind.DatatypeConverter +-dontwarn io.jsonwebtoken.impl.Base64Codec +-keepnames class com.fasterxml.jackson.** { * ; } +-keepnames interface com.fasterxml.jackson.** { *; } +-keep class org.sunbird.app.BuildConfig { *;} +-keep class android.webkit.WebViewFactory { *; } +-dontnote android.net.http.* +-dontnote org.apache.commons.codec.** +-dontnote org.apache.http.** +-keep class com.google.android.gms.** { *; } +-dontnote com.google.android.gms.** +-keep,includedescriptorclasses class com.journeyapps.barcodescanner.** { *; } +-keepclassmembers class com.journeyapps.barcodescanner.** { *; } +-keep,includedescriptorclasses class androidx.mediaandroid.webkit.WebViewFactory.** { *; } +-keepclassmembers class androidx.media.** { *; } +-keep class androidx.versionedparcelable.VersionedParcel +-dontnote android.webkit.WebViewFactory +-dontnote me.leolin.shortcutbadger.impl.AsusHomeLauncher +-dontnote me.leolin.shortcutbadger.impl.SolidHomeBadger +-dontnote com.android.org.conscrypt.SSLParametersImpl +-dontnote org.apache.harmony.xnet.provider.jsse.SSLParametersImpl +-dontnote org.conscrypt.ConscryptEngineSocket +-dontnote sun.security.ssl.SSLContextImpl +-dontnote org.crosswalk.engine.XWalkWebViewEngine +-dontnote com.google.firebase.crash.FirebaseCrash +-dontnote me.leolin.shortcutbadger.impl.XiaomiHomeBadger +-dontnote okhttp3.internal.platform.AndroidPlatform$CloseGuard + From 33f95144b41bd83a9840c66e1b78df5252c16498 Mon Sep 17 00:00:00 2001 From: subranil Date: Thu, 16 Jul 2020 10:24:09 +0530 Subject: [PATCH 2/6] Issue #SB-19779 feat: modified buildscripts, plugins --- build.sh | 2 - buildConfig/build-extras.gradle | 2 - build_config | 1 + proguard-custom.txt | 113 +------------------------------- 4 files changed, 2 insertions(+), 116 deletions(-) diff --git a/build.sh b/build.sh index 0173a15be..73f4d6bf7 100755 --- a/build.sh +++ b/build.sh @@ -44,8 +44,6 @@ rm -rf platforms #need to inspect on webpack dependdencies at the earliest NODE_OPTIONS=--max-old-space-size=4096 ionic cordova platforms add android@8.1.0 -cp "proguard-custom.txt" "www" - NODE_OPTIONS=--max-old-space-size=4096 ionic cordova build android --prod --release --buildConfig ./buildConfig/build.json npm run ionic-build diff --git a/buildConfig/build-extras.gradle b/buildConfig/build-extras.gradle index d1efa1ab8..934dddcc9 100644 --- a/buildConfig/build-extras.gradle +++ b/buildConfig/build-extras.gradle @@ -90,8 +90,6 @@ android { release { buildConfigField "boolean", "USE_CRASHLYTICS", "true" ext.enableCrashlytics = true - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'src/main/assets/www/proguard-custom.txt' } debug{ buildConfigField "boolean", "USE_CRASHLYTICS", "false" diff --git a/build_config b/build_config index d6b117d57..6bab6ddba 100644 --- a/build_config +++ b/build_config @@ -30,3 +30,4 @@ sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-qr-scan sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-sunbirdsplash.git#release-3.0.0 sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-file-support.git sunbird-cordova-plugin=https://github.com/swayangjit/sb-cordova-plugin-sync.git +cordova-plugin=https://github.com/greybax/cordova-plugin-proguard.git \ No newline at end of file diff --git a/proguard-custom.txt b/proguard-custom.txt index 3bf020ee6..e2dee1417 100644 --- a/proguard-custom.txt +++ b/proguard-custom.txt @@ -1,113 +1,3 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: -#-dontshrink -#-dontoptimize -#-dontobfuscate - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class android.webkit.WebView { -# public *; -#} - -#-injars bin/classes -#-injars libs -#-outjars bin/classes-processed.jar - -# Using Google's License Verification Library --keep class com.android.vending.licensing.ILicensingService - -# Specifies to write out some more information during processing. -# If the program terminates with an exception, this option will print out the entire stack trace, instead of just the exception message. --verbose - -# Annotations are represented by attributes that have no direct effect on the execution of the code. --keepattributes *Annotation* - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keepattributes InnerClasses --keep class **.R --keep class **.R$* { - ; -} - -# These options let obfuscated applications or libraries produce stack traces that can still be deciphered later on --renamesourcefileattribute SourceFile --keepattributes SourceFile,LineNumberTable - -# Enable proguard with Cordova --keep class org.apache.cordova.** { *; } --keep public class * extends org.apache.cordova.CordovaPlugin - --keep class com.google.android.gms.dynamite.DynamiteModule$DynamiteLoaderClassLoader { java.lang.ClassLoader sClassLoader; } - --keep class org.apache.cordova.CordovaBridge { org.apache.cordova.PluginManager pluginManager; } --keep class org.apache.cordova.CordovaInterfaceImpl { org.apache.cordova.PluginManager pluginManager; } --keep class org.apache.cordova.CordovaResourceApi { org.apache.cordova.PluginManager pluginManager; } --keep class org.apache.cordova.CordovaWebViewImpl { org.apache.cordova.PluginManager pluginManager; } --keep class org.apache.cordova.ResumeCallback { org.apache.cordova.PluginManager pluginManager; } --keep class org.apache.cordova.engine.SystemWebViewEngine { org.apache.cordova.PluginManager pluginManager; } - --dontnote org.apache.harmony.xnet.provider.jsse.NativeCrypto --dontnote sun.misc.Unsafe - --keep class com.worklight.androidgap.push.** { *; } --keep class com.worklight.wlclient.push.** { *; } - -# Enable proguard with Google libs --keep class com.google.** { *; } --dontwarn com.google.common.** --dontwarn com.google.ads.** --dontwarn com.google.android.gms.** - -# apache.http --optimizations !class/merging/vertical*,!class/merging/horizontal*,!code/simplification/arithmetic,!field/*,!code/allocation/variable - --keep class net.sqlcipher.** { *; } --dontwarn net.sqlcipher.** - --keep class org.codehaus.** { *; } --keepattributes *Annotation*,EnclosingMethod - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - -# Remove debug logs in release build --assumenosideeffects class android.util.Log { - public static *** d(...); -} - -# These classes contain references to external jars which are not included in the default MobileFirst project. --dontwarn com.worklight.common.internal.WLTrusteerInternal* --dontwarn com.worklight.jsonstore.** --dontwarn org.codehaus.jackson.map.ext.* --dontwarn com.worklight.androidgap.push.GCMIntentService --dontwarn com.worklight.androidgap.plugin.WLInitializationPlugin - --dontwarn android.support.v4.** --dontwarn android.net.SSLCertificateSocketFactory --dontwarn android.net.http.* - -# These clases contain references to cordova webView --keep class com.ionicframework.cordova.webview.** {*; } --keep class com.ionicframework.cordova.webview.* -dontwarn java.awt.**,javax.swing.** -dontwarn org.mozilla.javascript.tools.** @@ -164,5 +54,4 @@ -dontnote org.crosswalk.engine.XWalkWebViewEngine -dontnote com.google.firebase.crash.FirebaseCrash -dontnote me.leolin.shortcutbadger.impl.XiaomiHomeBadger --dontnote okhttp3.internal.platform.AndroidPlatform$CloseGuard - +-dontnote okhttp3.internal.platform.AndroidPlatform$CloseGuard \ No newline at end of file From 52ffb5d96724031dbe3e55aca593f1473c585a3a Mon Sep 17 00:00:00 2001 From: swayangjit Date: Thu, 16 Jul 2020 23:40:07 +0530 Subject: [PATCH 3/6] Issue #SB-19779: Added proguard plugin in package.json. --- config.xml | 1 + package-lock.json | 4 ++++ package.json | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config.xml b/config.xml index 1fa7718c7..fe9cb4e78 100644 --- a/config.xml +++ b/config.xml @@ -153,4 +153,5 @@ + diff --git a/package-lock.json b/package-lock.json index 7a5945a82..a47889e23 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7583,6 +7583,10 @@ "resolved": "https://registry.npmjs.org/cordova-plugin-printer/-/cordova-plugin-printer-0.8.0.tgz", "integrity": "sha512-Olu2SuCedztO6PtXoHwA4J/emOxZlj64Ya9aZhcxoXJITG+RDF6Nb3oThcpYPTa73+py+gPF7r19lv3Q8RR/Nw==" }, + "cordova-plugin-proguard": { + "version": "git+https://github.com/greybax/cordova-plugin-proguard.git#e7ceaddc5e1e77425fa251062304045f8682a483", + "from": "git+https://github.com/greybax/cordova-plugin-proguard.git" + }, "cordova-plugin-qr-scanner": { "version": "git+https://github.com/project-sunbird/cordova-plugin-qr-scanner.git#321e74b7ad06f93ff3aad239882b99a6fad29cdf", "from": "git+https://github.com/project-sunbird/cordova-plugin-qr-scanner.git" diff --git a/package.json b/package.json index 5c9b6ab11..5bb6ce2f4 100644 --- a/package.json +++ b/package.json @@ -79,6 +79,7 @@ "cordova-plugin-network-information": "^2.0.2", "cordova-plugin-openrap": "git+https://github.com/project-sunbird/cordova-plugin-openrap.git", "cordova-plugin-printer": "^0.8.0", + "cordova-plugin-proguard": "git+https://github.com/greybax/cordova-plugin-proguard.git", "cordova-plugin-qr-scanner": "git+https://github.com/project-sunbird/cordova-plugin-qr-scanner.git", "cordova-plugin-screen-orientation": "^3.0.2", "cordova-plugin-statusbar": "^2.4.3", @@ -197,7 +198,8 @@ "ANDROID_DEFAULT_NOTIFICATION_ICON": "@mipmap/ic_launcher" }, "com.telerik.plugins.nativepagetransitions": {}, - "sb-cordova-plugin-sync": {} + "sb-cordova-plugin-sync": {}, + "cordova-plugin-proguard": {} }, "platforms": [ "android" From 2fd94f77517c817df2e64d80d8a8847cfbf4dceb Mon Sep 17 00:00:00 2001 From: subranil Date: Fri, 17 Jul 2020 12:01:31 +0530 Subject: [PATCH 4/6] Issue #SB-19779 fix: proguard-custom fix for jenkins build --- proguard-custom.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proguard-custom.txt b/proguard-custom.txt index e2dee1417..c325cfde7 100644 --- a/proguard-custom.txt +++ b/proguard-custom.txt @@ -38,7 +38,6 @@ -dontnote org.apache.commons.codec.** -dontnote org.apache.http.** -keep class com.google.android.gms.** { *; } --dontnote com.google.android.gms.** -keep,includedescriptorclasses class com.journeyapps.barcodescanner.** { *; } -keepclassmembers class com.journeyapps.barcodescanner.** { *; } -keep,includedescriptorclasses class androidx.mediaandroid.webkit.WebViewFactory.** { *; } @@ -54,4 +53,5 @@ -dontnote org.crosswalk.engine.XWalkWebViewEngine -dontnote com.google.firebase.crash.FirebaseCrash -dontnote me.leolin.shortcutbadger.impl.XiaomiHomeBadger --dontnote okhttp3.internal.platform.AndroidPlatform$CloseGuard \ No newline at end of file +-dontnote okhttp3.internal.platform.AndroidPlatform$CloseGuard +-keep class com.google.android.gms.internal.zzak$zza \ No newline at end of file From 12cce122b86592af7683ff6e2ae37fb5c98246a3 Mon Sep 17 00:00:00 2001 From: subranil Date: Fri, 17 Jul 2020 20:12:37 +0530 Subject: [PATCH 5/6] Issue #SB-19779 feat: modified proguard rules --- proguard-custom.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/proguard-custom.txt b/proguard-custom.txt index c325cfde7..dce831448 100644 --- a/proguard-custom.txt +++ b/proguard-custom.txt @@ -54,4 +54,11 @@ -dontnote com.google.firebase.crash.FirebaseCrash -dontnote me.leolin.shortcutbadger.impl.XiaomiHomeBadger -dontnote okhttp3.internal.platform.AndroidPlatform$CloseGuard --keep class com.google.android.gms.internal.zzak$zza \ No newline at end of file +-dontnote com.google.android.gms.internal.measurement.** + +-keepclassmembers class com.google.android.gms.** { *; } +-dontnote android.os.** +-dontnote com.google.android.gms.ads.AdView +-dontnote com.google.android.gms.common.api.internal.BasePendingResult$ReleasableResultGuardian +-dontnote com.google.android.gms.tagmanager.TagManagerService +-dontnote com.google.android.gms.common.api.internal.BasePendingResult \ No newline at end of file From 88258d8f001d9d8c2d50af4182a1934913af52d6 Mon Sep 17 00:00:00 2001 From: subranil Date: Tue, 21 Jul 2020 18:26:21 +0530 Subject: [PATCH 6/6] Issue #SB-19779 fix: update proguard-custom.txt --- build_config | 4 ++-- proguard-custom.txt | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build_config b/build_config index 6bab6ddba..b0e1394ad 100644 --- a/build_config +++ b/build_config @@ -20,6 +20,7 @@ cordova-plugin=cordova-plugin-android-permissions cordova-plugin=cordova-plugin-media cordova-plugin=cordova.plugins.diagnostic cordova-plugin=com.telerik.plugins.nativepagetransitions +cordova-plugin=https://github.com/greybax/cordova-plugin-proguard.git cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-utility.git#release-3.0.0 cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-downloadmanager.git#release-2.9.0 cordova-plugin=https://github.com/Sunbird-Ed/sb-cordova-plugin-db.git#release-3.1.0 @@ -29,5 +30,4 @@ sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-openrap sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-qr-scanner.git sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-sunbirdsplash.git#release-3.0.0 sunbird-cordova-plugin=https://github.com/project-sunbird/cordova-plugin-file-support.git -sunbird-cordova-plugin=https://github.com/swayangjit/sb-cordova-plugin-sync.git -cordova-plugin=https://github.com/greybax/cordova-plugin-proguard.git \ No newline at end of file +sunbird-cordova-plugin=https://github.com/swayangjit/sb-cordova-plugin-sync.git \ No newline at end of file diff --git a/proguard-custom.txt b/proguard-custom.txt index dce831448..b0ab43df5 100644 --- a/proguard-custom.txt +++ b/proguard-custom.txt @@ -61,4 +61,9 @@ -dontnote com.google.android.gms.ads.AdView -dontnote com.google.android.gms.common.api.internal.BasePendingResult$ReleasableResultGuardian -dontnote com.google.android.gms.tagmanager.TagManagerService --dontnote com.google.android.gms.common.api.internal.BasePendingResult \ No newline at end of file +-dontnote com.google.android.gms.common.api.internal.BasePendingResult +-dontnote com.google.android.gms.gcm.GcmListenerService + +-keep class com.google.android.gms.** { *; } +-keep public class com.google.android.gms.* { public *; } +-dontwarn com.google.android.gms.** \ No newline at end of file