Flutter reduce app size App size is the most important in the term of the apps usage and user retention in an app. Many people are a...
Flutter reduce app size |
App size is the most important in the term of the apps usage and user retention in an app. Many people are asking me about the app size reducing even if they have optimized at their best at coding and asset management. So here is how you can reduce apps size and make it smaller than your normal apk or aab. From the technique in this tutorial you will be able to reduce apk size upto 50%.
Before
Before |
After
After |
In Production
in Production |
Steps to follow:
- Add the following code in your android/app/build.gradle file
android/app/build.gradle |
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
## Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-keep class com.google.firebase.** { *; }
-dontwarn io.flutter.embedding.**
-ignorewarnings
- if you don't have firebase in your project then use the following code
## Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
-dontwarn io.flutter.embedding.**
-ignorewarnings
If you build apk you can see about the 20% reduce in size in my case 20mb to 16mb and in the bundle you can see the release apk reduce by 50% , In my case 10mb apk from bundle the app tested in this tutorial can be downloaded from button below:
Download
error |
- just remove the text from last step from gradle.properties
extra-gen-snapshot-options=--obfuscate
ty
ReplyDeletekeep subscribed for more content
Delete