-
-
Notifications
You must be signed in to change notification settings - Fork 48
Proguard
The size of Android applications has been increasing for years.
To make your app as small as possible, you should enable shrinking option in your release build to remove unused code and resources. When enabling shrinking option, you also benefit from obfuscation which shortens the names of your app’s classes and members, and optimization which applies more aggressive strategies to further reduce the size of your app.
Enable D8 shrinker on gradle.properties
android.enableD8=true
All proguard rules:
- model-rules.pro
- support-rules.pro
- apache-rules.pro
- gson-rules.pro
- okhttp3-rules.pro
- retrofit2-rules.pro
- stetho-rules.pro
Defined on dependencies.gradle:
// PROGUARD
proguardFolder = '../proguard/'
modelRules = proguardFolder + 'model-rules.pro'
supportRules = proguardFolder + 'support-rules.pro'
apacheRules = proguardFolder + 'apache-rules.pro'
gsonRules = proguardFolder + 'gson-rules.pro'
okhttp3Rules = proguardFolder + 'okhttp3-rules.pro'
retrofit2Rules = proguardFolder + 'retrofit2-rules.pro'
stethoRules = proguardFolder + 'stetho-rules.pro'
Add on Data module:
release {
minifyEnabled true
consumerProguardFiles modelRules, supportRules, apacheRules, gsonRules, okhttp3Rules, retrofit2Rules, stethoRules
}
Enable on Presentation module:
release {
signingConfig signingConfigs.release
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
}
debugTest
like this:
debugTest {
initWith(debug)
minifyEnabled false
}
testBuildType 'debugTest'
Find this project useful? Support it by joining stargazers for this repository ⭐️
And follow me for my next creations 👍
CleanRxArchitecture by Lopez Mikhael is licensed under a Apache License 2.0.