当前位置:网站首页>亲测flutter打包apk后大小,比较满意
亲测flutter打包apk后大小,比较满意
2022-06-30 17:28:00 【可口码农】
flutter我虽然知道的早,但是还没有使用过,今天就第一次打包Android APK试试大小,因为选择flutter我必须考虑他的包大小,如果它打包apk比react native还要大我肯定不考虑。
在打包之前我猜apk应该会很大,起码30m左右,但是当我把release包build出来后,我大吃一惊,很满意!
首次安装 flutter SDK是3.0.2,是当前最新版。
安装配置好环境变量PATH后,重新命令行界面,就可以通过 flutter doctor命令确认已经安装成功。
flutter doctor然后使用flutter create learn_flutter
flutter create learn_flutter项目几秒就创建成功,这点比react-native体验好多了。
然后我开始flutter run运行,竟然不成功!大概错误内容是:
License for package Android SDK Build-Tools 30.0.3 not accepted.
我以为是我的工具安装不对,但是我怎么搜都找不到30.0.3的工具呀!网上回答都是sdk tool中安装,可我找不到30.0.3的版本。
后来发现是flutter 的android sdk配置路径问题。应该一下这样的命令来配置flutter应用的android sdk
flutter config --android-sdk /path/to/android/sdkflutter config --android-studio-dir /path/to/android/studio重要提醒:千万不要在 android项目的根文件 local.properties中配置。我折腾了一个小时就是因为在这里像安卓项目和react native那样配置android sdk路径。每一次运行 flutter run命令,这个配置又恢复到不正确的路径了。
正确配置好 android adk路径后,就可以在模拟器里运行了,我尝试改了改代码,能够正确在模拟器里看到效果!确定这步没问题了。
我准备开始 build release版本的 apk,但是我碰到新问题了,结果大概是需要java11来打包apk。!不管了,我安装java11.
安装好java11后(环境变量替换了java8)需要在Android工程的gradle.properties文件中添加如下jdk的路径
org.gradle.java.home=path/Java/jdk-11.0.15.1并修改Android工程app\build.gradle文件。

好了,终于可以build apk了。build release apk需要以下命令。
flutter build apk --target-platform android-arm,android-arm64flutter build apk --target-platform android-arm,android-arm64 --split-per-abi命令说明以下:
⾸先 flutter build apk 表⽰当前构建 release 包
后⾯ android-arm,android-arm64,android-x64则是指定⽣成对应架构的release包
最后的 --split-per-abi则表⽰告知需要按照我们指定的类型分别打包,如果移除则直接构建包含所有 CPU 架构的 Apk 包。
--obfuscate:开启混淆操作
--split-debug-info=:将因混淆⽣成的 map 符号表缓存到此位置
第一串命令打包出来的 armv8a和armv7a的单指令集apk大约是5.8M,我很惊讶!这算小的了。

第二串命令打包出来的armv8a和armv7a指令集合并在一个apk的大小是 10.6M,我一样很惊讶!很满意!

最终得出一个结论,flutter 3.0 release apk 和 react native 0.68 release apk 大小是差不多的。
关注我站,www.zchawang.cn,一个小工具站。
边栏推荐
- How to do a good job in software system demand research? Seven weapons make it easy for you to do it
- depends工具查看exe和dll依赖关系
- Conception d'un centre commercial en ligne basé sur SSH
- MRO工业品采购管理系统:赋能MRO企业采购各节点,构建数字化采购新体系
- Rhai - Rust 的嵌入式脚本引擎
- Rust 书籍资料 - 芽之家书馆
- [cloud resident co creation] Huawei iconnect enables IOT terminals to connect at one touch
- Dropout: immediate deactivation
- 「经验」我对用户增长的理解『新用户篇』
- Three methods of modifying time zone in MySQL
猜你喜欢

Classic problem of leetcode dynamic programming (I)

Post office - post office issues (dynamic planning)

It's not easy to say I love you | use the minimum web API to upload files

Infineon - GTM architecture -generic timer module

小程序容器技术,促进园区运营效率提升

医院在线问诊小程序源码 互联网医院源码 智慧医院源码

Oneortwo bugs in "software testing" are small things, but security vulnerabilities are big things. We must pay attention to them

countdownlatch 和 completableFuture 和 CyclicBarrier

How to solve the lock-in read-only alarm of AutoCAD Chinese language?

漏洞复现----37、Apache Unomi 远程代码执行漏洞 (CVE-2020-13942)
随机推荐
MySQL advanced - Architecture
助力极致体验,火山引擎边缘计算最佳实践
漏洞复现----38、ThinkPHP5 5.0.23 远程代码执行漏洞
Dropout: immediate deactivation
Electronic components bidding and purchasing Mall: optimize traditional purchasing business and speed up enterprise digital upgrading
Solution of enterprise supply chain system in medical industry: realize collaborative visualization of medical digital intelligent supply chain
系统集成项目管理工程师认证高频考点:编制项目范围管理计划
One script of unity actual combat realizes radar chart
【TiDB】TiCDC canal_json的实际应用
Do you really understand the persistence mechanism of redis?
Force deduction solution summary 1175- prime number arrangement
GameFi链游系统开发NFT技术
If you want to learn software testing, you must see series, 2022 software testing engineer's career development
Vulnerability recurrence ----37. Apache unomi Remote Code Execution Vulnerability (cve-2020-13942)
Summary of methods for offline installation of chrome extensions in China
Geoffrey Hinton: my 50 years of in-depth study and Research on mental skills
【TiDB】TiCDC canal_ Practical application of JSON
MRO industrial products procurement management system: enable MRO enterprise procurement nodes to build a new digital procurement system
SaaS project management system solution for the financial service industry helps enterprises tap a broader growth service space
Unity实战之一个脚本实现雷达图