Optimize APK size by fixing R8 rules and excluding some BC resources

This commit is contained in:
Alexander Bakker 2022-10-09 17:18:13 +02:00
parent 80c37556c7
commit 8ea28327db
2 changed files with 13 additions and 30 deletions

View file

@ -79,16 +79,18 @@ android {
]
buildConfigField("String", "FILE_PROVIDER_AUTHORITY", "\"${fileProviderAuthority}\"")
resValue "bool", "pref_secure_screen_default", "true"
postprocessing {
removeUnusedCode true
removeUnusedResources true
obfuscate false
optimizeCode true
proguardFiles getDefaultProguardFile('proguard-defaults.txt'), 'proguard-rules.pro'
}
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
// R8 doesn't remove these resources, so exclude them manually. This reduces APK size by 4MB.
exclude '/org/bouncycastle/pqc/**/*.properties'
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
@ -168,7 +170,7 @@ dependencies {
implementation 'de.psdev.licensesdialog:licensesdialog:2.2.0'
implementation 'net.lingala.zip4j:zip4j:2.11.2'
implementation 'info.guardianproject.trustedintents:trustedintents:0.2'
implementation 'org.bouncycastle:bcprov-jdk15to18:1.72'
implementation 'org.bouncycastle:bcprov-jdk18on:1.72'
implementation "org.simpleflatmapper:sfm-csv:8.2.3"
androidTestAnnotationProcessor "com.google.dagger:hilt-android-compiler:$hiltVersion"

View file

@ -1,25 +1,6 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /home/alex/Android/Sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# 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 *;
#}
-keepclasseswithmembers public class androidx.recyclerview.widget.RecyclerView { *; }
-keep class com.beemdevelopment.aegis.ui.fragments.*
-keep class com.beemdevelopment.aegis.ui.fragments.preferences.*
-keep class com.beemdevelopment.aegis.importers.** { *; }
-keep class * extends com.google.protobuf.GeneratedMessageLite { *; }
-keep class !org.bouncycastle.jce.provider.X509LDAPCertStoreSpi { *; }
-dontwarn javax.naming.**