java - 如何在 Android Studio 中压缩 Kotlin 项目
问题描述
我在 android studio 中创建了一个 android 应用程序,对于编程语言我使用了Kotlin。
现在我的应用程序完成了,我想构建我的应用程序,但是在构建应用程序后显示35mb的应用程序大小!!!
我的可绘制文件夹大小有2mb并且没有任何更大的文件,但是为什么我的应用程序大小是35mb ?!!!
为了生成测试 apk 版本,我使用了Build -> Build bundle/Apk -> Build apk from android studio menu。
但是当使用java作为语言时,这个大小是7mb !!!
我该如何解决?
解决方案
Some random ideas to improve your apk size:
- Turn on minification (ProGuard or R8, use the property
minifyEnabled
), recheck your ProGuard files if you are not excluding too much - Convert your images to
webp
files, or vectors, which are even better - Add an
abiFilter
, which excludes ancient ABIs, such asmips
- Use Android App Bundles, which splits the apk per language, ABI and screen resolution, essentially reducing the delivered APK size
- Check if you have any libraries you don't use anymore
- Filter out any unsupported languages with the
resConfigs
attribute
Android also has a documentation about this, which goes into more detail.
推荐阅读
- php - 表中的服务器端数据表实现
- xamarin.uwp - 在 Xamarin ListView 中调用 ScrollTo 方法时 UWP UI 冻结
- angular - ngModel 没有更新 ionic 3 中的输入类型
- python - BeautifulSoup4 找不到正确的元素
- ios - Swift 4 SpriteKit 检测联系人
- database - 出现 SQL 错误:ORA-01847:运行我的语句时,月中的某天必须介于 1 和月的最后一天之间
- java - 我想在可编辑 JTable 的单元格中写入时更改字体大小
- angular - Angular 4:从服务返回承诺进入无限循环
- android - Android studio3.1:插件Android支持中的异常
- ios - npm install -g ios-deploy 没有工作,它显示错误