Google PlayStore中我的应用程序捆绑包下载大小约为23 MB:
但是,为什么安装后,磁盘上的应用程序大小显着增加到83 MB:
任何想法为什么会这样,因为:
1)Flutter的资产文件(图像,声音和字体)仅在11 MB左右的项目上
2)磁盘上Flutter源代码(.dart)的大小仅为1.4 MB
3)Android Native Resource / icon(Res)仅约800 KB
关于我在下面使用的flutter插件:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
angles: ^1.0.1
app_settings: ^1.0.5
archive: ^2.0.8
cached_network_image: ^1.1.1
carousel_slider: ^1.3.0
cron: ^0.2.1
crypto: ^2.0.6
cupertino_icons: ^0.1.2
date_format: ^1.0.5
device_id: ^0.1.3
dio: ^2.0.0
easy_alert: ^0.0.2
localstorage: ^2.0.0
audioplayers: ^0.13.1
path_provider: ^1.1.0
esys_flutter_share: ^1.0.2
flutter_compass: ^0.3.2
flutter_html: ^0.9.6
flutter_local_notifications: ^0.8.2
flutter_offline: ^0.2.4+1
flutter_swiper: ^1.1.6
flutter_xlider: ^2.4.5
font_awesome_flutter: ^8.2.0
geolocator: ^5.0.1
google_maps_flutter: ^0.2.0
google_sign_in: ^4.0.1+1
http: ^0.12.0+2
libcalendar: ^0.2.0
location : ^2.3.0
numberpicker: ^1.0.0
pigment: ^1.0.3
rxdart: ^0.21.0
shared_preferences: ^0.5.1+1
shimmer: ^1.0.0
unicode: ^0.1.0
url_launcher: ^5.0.2
validate: ^1.6.0
vibrate: ^0.0.4
after_layout: ^1.0.7+2
draggable_scrollbar: ^0.0.4
flutter_web_browser: ^0.11.0
flutter_youtube: ^1.1.6
google_api_availability: ^2.0.1
indexed_list_view: ^0.0.5
permission_handler: ^3.1.0
queries: ^0.1.4
rect_getter: ^0.0.1
scroll_to_index: any
sqflite: ^1.1.5
tuple: ^1.0.2
xml2json: ^3.0.3
firebase_messaging: ^5.1.6
firebase_analytics: ^3.0.2
firebase_core: ^0.4.0+3
firebase_auth: ^0.11.1+6
firebase_admob: ^0.9.0+1
firebase_in_app_messaging: ^0.0.1+3
superellipse_shape: ^0.1.5
device_info: ^0.4.0+2
in_app_purchase: ^0.2.0+6
sentry: any
system_info: ^0.1.1
highlighter_coachmark: ^0.0.3
volume: ^0.1.0
admob_flutter: ^0.3.2
bubble_tab_indicator: "^0.1.4"
material_design_icons_flutter: ^3.0.3289
scoped_model: ^1.0.1
flutter_slidable: ^0.4.9
kiwi: ^0.1.0
flutter_markdown: ^0.2.0
flutter_downloader: ^1.2.1
native_ads: ^0.2.0
onesignal_flutter: ^2.0.0
任何想法如何减少应用程序的大小?
先感谢您...
更新
如果我在中设置minifyEnabled = true
和shrinkResources = true
(如Ravinder Kumar的建议),build.gradle
它将产生一个很长的错误,这是日志:
==为Android构建==
... (由于时间过长,我剪切了错误日志,但是完整的日志可以在这里看到:https : //www.dropbox.com/s/jy92d1lmj9pgb6d/full_flutter_error_log.txt?dl=0)
注意:该配置会保留入口点'io.flutter.plugins.googlesignin.GoogleSignInPlugin $ Delegate $ 3 {void onComplete(com.google.android.gms.tasks.Task); }”,但不是描述符类“ com.google.android.gms.tasks.Task”
注意:该配置会保留入口点'io.flutter.plugins.inapppurchase.Translator {java.util.HashMap fromSkuDetail(com.android.billingclient.api.SkuDetails); }”,但不是描述符类“ com.android.billingclient.api.SkuDetails”
注意:该配置会保留入口点'io.flutter.plugins.inapppurchase.Translator {java.util.HashMap fromPurchase(com.android.billingclient.api.Purchase); }”,但不是描述符类“ com.android.billingclient.api.Purchase”
注意:该配置会保留入口点'io.flutter.plugins.inapppurchase.Translator {java.util.HashMap fromPurchasesResult(com.android.billingclient.api.Purchase $ PurchasesResult); }”,但不是描述符类“ com.android.billingclient.api.Purchase $ PurchasesResult”
注意:有7个对未知类的引用。
You should check your configuration for typos. (http://proguard.sourceforge.net/manual/troubleshooting.html#unknownclass)
注意:有3个对未知类成员的引用。
You should check your configuration for typos.
注意:保留的类成员中有242个未定义的描述符类。
You should consider explicitly keeping the mentioned classes (using '-keep'). (http://proguard.sourceforge.net/manual/troubleshooting.html#descriptorclass)
注意:有68个未解决的对类或接口的动态引用。
You should check if you need to specify additional program jars. (http://proguard.sourceforge.net/manual/troubleshooting.html#dynamicalclass)
警告:有25个未解决的对类或接口的引用。
You may need to add missing library jars or update their versions. If your code works fine without the missing classes, you can suppress the warnings with '-dontwarn' options. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
警告:有2个未解决的对库类成员的引用。
You probably need to update the library versions. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
警告:处理任务java.io.IOException时发生异常:请首先更正以上警告。
线程(任务限制器_1):销毁运行Gradle任务'bundleRelease'... 690.7s(!)
****************************************************** **********************> ******************* Gradle失败可能是由于AndroidX>此Flutter应用程序中的不兼容性。有关该问题以及如何解决此问题的更多信息,请参见“ https://goo.gl / CP92wY”。****************************************************** **********************> ******************* Gradle任务包发布失败,退出代码为1
构建失败:| 无法为Android构建
顺便说一句,下面是我的proguard-rules.pro
:
#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.baseflow.** { *; }
#-keep class com.chartboost.** { *; }
-dontwarn com.google.common.base.**
-keep class com.google.common.base.** {*;}
-dontwarn com.google.errorprone.annotations.**
-keep class com.google.errorprone.annotations.** {*;}
-dontwarn com.google.j2objc.annotations.**
-keep class com.google.j2objc.annotations.** { *; }
-dontwarn java.lang.ClassValue
-keep class java.lang.ClassValue { *; }
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-keep class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement { *; }