How to reduce flutter app size and obfuscation ?

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   
    }   
   }   
  }   

  • In the same directory create a file called proguard-rules.pro 
    proguard-rules.pro
  • If you have firebase implemented in your project then use the following content

 ## 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  

  • In your gradle.properties file add the following line
 extra-gen-snapshot-options=--obfuscate   

 gradle.properties

  • Now you are done build the apk using the following command to see the effect
      flutter build apk --release  
  • or bundle using
     flutter build appbundle --release

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 








  • If you encounter an error like below 
  • error

    • just remove the text from last step from gradle.properties
     extra-gen-snapshot-options=--obfuscate   
    


    Video Tutorial

    COMMENTS

    BLOGGER: 2

    Name

    adblocker,1,adobe,1,AI,1,android,14,anti adblocker,1,aritificial intelligence,1,best hosting,1,block adblock,1,busybox,1,commands,4,crack,9,cross-platform,1,csit,1,Download,2,edu email,1,facebook,4,fifa,1,flutter,1,free mastercard,1,game,1,google drive,1,HACK,5,hacking,7,how to remove community strike,1,instagram,1,ios,1,kali linux,1,linux,8,mastercard,1,microsoft,1,mod apk,3,nepali unicode,1,Notes,2,old question,1,payoneer,1,phising,1,programming,4,PUBG,3,PUBG HACK,1,root,1,strike removal,1,Tech,5,terminal,3,termux,1,Tricks,29,virus,1,windows,11,youtbe,1,youtube,2,
    ltr
    item
    SIDTUBE: How to reduce flutter app size and obfuscation ?
    How to reduce flutter app size and obfuscation ?
    https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDlvMiRzXMcZnp7vySfmfq1XfJ9fdikKrIg4JEnwKsHbhUFN6Lf7q3M7xrs8YpHnudmruTO4IKKpfXkxnOR7HAiozUF3FucAzBg3F1CkUeTJeidGMb-osP59rRT3guXWfAjfdwqD-eLJry/s640/Flutter+reduce+app.png
    https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDlvMiRzXMcZnp7vySfmfq1XfJ9fdikKrIg4JEnwKsHbhUFN6Lf7q3M7xrs8YpHnudmruTO4IKKpfXkxnOR7HAiozUF3FucAzBg3F1CkUeTJeidGMb-osP59rRT3guXWfAjfdwqD-eLJry/s72-c/Flutter+reduce+app.png
    SIDTUBE
    https://www.siddharthajoshi.com.np/2019/12/how-to-reduce-flutter-app-size-and.html
    https://www.siddharthajoshi.com.np/
    https://www.siddharthajoshi.com.np/
    https://www.siddharthajoshi.com.np/2019/12/how-to-reduce-flutter-app-size-and.html
    true
    8327815029698999663
    UTF-8
    Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content