I have recently switched from Android native Java platform to Flutter. From tutorials and online information I understand that dubug app size could be large but not the release one.
Flutter releasebuild bundle is 123.7 MBs. And when installed, app size increase to about 300 to 350 MBs.
I have no media in assets. All mipmap and drawables are minified to total of less then 100 kbs.
I have this app where I am using following plugins:
cupertino_icons: ^1.0.2
flutter_native_splash: ^1.2.3
firebase_core:
firebase_auth: ^3.1.3
cloud_firestore: ^2.5.3
firebase_messaging: ^10.0.8
firebase_storage: ^10.0.5
sqflite: ^2.0.0+4
path_provider: ^2.0.5
permission_handler: ^8.1.6
pinput: ^1.2.0
flutter_launcher_icons: ^0.9.2
http: ^0.13.3
flutter_local_notifications: ^8.2.0
contacts_service: ^0.6.3
intl: ^0.17.0
file_picker: ^4.1.4
cached_network_image: ^3.1.0
provider: ^6.0.1
awesome_notifications: any
flutter_sound: ^8.4.1+1
stream_transform: ^2.0.0
jitsi_meet: ^4.0.0
dio: ^4.0.1
google_fonts: ^2.1.0
share_plus: ^3.0.4
fluttertoast: ^8.0.8
connectivity_plus: ^2.0.2
shared_preferences: ^2.0.8
random_string: ^2.3.1
I am using Proguard in gradle:
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
And proguard-rule file:
## 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
Also I have tried to clean and run build query like below, but no difference:
flutter clean && flutter build appbundle
Any suggestion and help would be appreciated.
UPDATE:
As suggested by שו אוהב אותך, problem seems to be with flutter_sound plugin. I switched from flutter_sound to flutter_sound_lite and tried to rebuild. Now I get error.
Attribute receiver#androidx.media.session.MediaButtonReceiver@exported value=(false) from [:awesome_notifications] AndroidManifest.xml:59:13-37 is also present at [com.github.canardoux:flutter_sound_core:8.4.2] AndroidManifest.xml:18:13-36 value=(true). Suggestion: add 'tools:replace="android:exported"' to element at AndroidManifest.xml:57:9-63:20 to override.
Manifest:
<activity> // Main Activity
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
Any suggestion? Thanks.
As suggested by שו אוהב אותך, problem seems to be with flutter_sound plugin. I switched from flutter_sound to flutter_sound_lite but problem remained.
So finally I ended up developing my own plugin for Flutter. Currently it's working for android only but will be brought available for IOS soon.
Now my appbundle size has reduced to 47.6 MBs from 123.6 MBs.
Plugin link is given below if anyone has the same issue:
Flutter Sound System - Plugin Link