Android应用apk安装包的大小,虽然对于现在WiFi普及情况而言消耗流量已经微乎其微,但是,对于一款好的应用,对于一款负责任的应用,当然是越小越好了。

引言:

.应用越小,下载越快,也就意味着新用户能在最短时间内安装,体验应用,而不是看着通知栏里面的丑陋的下载进度条,盯着看几分钟(30-50M的应用很常见,网不好,下载几分钟很正常)就像这样...

. 随着应用的迭代,应用必须满足人们越来越高的体验需求,应用需要更多的代码,更多的第三方库,更多的资源文件,随着设备的分辨率越来越高,资源文件也是水涨船高,越来越大,最终导致应用大小一直上升.如果解压一个应用,查看他的分布,会发现,最占大小的是这3部分,classes.dex, resources.asrc , res folder. 有时候assets folder 也包含比较大的视频音频图片文件.there are some tools that can help you....whaha

正文:

优化点1:Apk Splits  对资源文件做优化配置

Density Splits

android {
...
splits {
density {
enable true
exclude "ldpi", "tvdpi", "xxxhdpi"
compatibleScreens 'small', 'normal', 'large', 'xlarge'
}
}
enable: enables the density split mechanism
exclude: By default all densities are included, you can remove some densities.
include: indicate which densities to be included
reset(): reset the list of densities to be included to an empty string (this allows, in conjunctions with include, to indicate which one to use rather than which ones to ignore)
compatibleScreens: indicates a list of compatible screens. This will inject a matching <compatible-screens><screen ...> node in the manifest. This is optional.
 
Note that this will also always generate a universal APK with all the densities.
 

ABIs Splits

android {
...
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a', 'mips'
universalApk true
}
}
}
enable: enables the ABIs split mechanism
exclude: By default all ABIs are included, you can remove some ABIs.
include: indicate which ABIs to be included
reset(): reset the list of ABIs to be included to an empty string (this allows, in conjunctions with include, to indicate which one to use rather than which ones to ignore)
universalApk: indicates whether to package a universal version (with all ABIs) or not. Default is false.

优化点2:WEBP 另外一种谷歌推的web图片格式,小!!!

具体用法,或者兼容低版本,都有解决方案。

优化点3:Vector Drawables..同理WEBP....

优化点4: 手动压缩图片,神器 imageoptim ,官网:https://imageoptim.com/mac

https://www.novoda.com/blog/leaner-apks-with-custom-asset-minification/

再谈Android应用瘦身的更多相关文章

  1. 包建强的培训课程(6):Android App瘦身优化

    v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM ...

  2. Android APK 瘦身 - JOOX Music项目实战

    导语 JOOX Music是腾讯海外布局的一个音乐产品,2014年发布以来已经成为5个国家和地区排名第一的音乐App.东南亚是JOOX Music的主要发行地区,由于JOOX Music所面对的市场存 ...

  3. Android应用瘦身

    转:https://zhuanlan.zhihu.com/p/25465537 瘦身的目的 从目的导向来看,我们是不会无缘无故去做一件事情的,那我们对应用瘦身的目的是为了什么?答案是:提高下载转化率. ...

  4. Android APK瘦身之Android Studio Lint (代码审查)

    ******** ******** 第一部分: 瘦身内容介绍 ******** ******** 项目新版本的迭代接近尾声, 因为历史累积问题, 导致有很多无效的资源让已经臃肿的APK变得更肿, 因此 ...

  5. 利用 Android Gradle 瘦身 apk

    http://devyang.me/blog/2014/11/11/li-yong-android-gradleshou-shen-apk/ apk瘦身一般有两条线, 去除无用的代码,例如引用一个比较 ...

  6. 关于Android图片资源瘦身的奇思妙想

    版权声明:本文由况鹰原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/77 来源:腾云阁 https://www.qcloud ...

  7. Android 7.1.1 又出幺蛾子了 —— 再谈 Android 上的 Wifi 连接

    在之前的博客文章中,我写了点在 Android 6 系统中连接到指定名称的 Wifi 的体验.然而,在 Android 7 中,有一些东西又变化了.另外就是在那篇文章中我说要提供代码,结果拖到这篇文章 ...

  8. Android Apk 瘦身大法

    原文地址: https://mp.weixin.qq.com/s/XS0tuLgTfyp4rW4h69wyQQ 一, 我们在多人开发项目 或者 遗留项目中开发时,会有些自己没用到的资源文件,但是自己也 ...

  9. android apk瘦身之 图片压缩 tinypng

    参考地址: http://blog.csdn.net/jy692405180/article/details/52409369 http://www.tuicool.com/articles/BraI ...

随机推荐

  1. 通过js引入当前所需要的js,css等

    在我们web前端页面中经常会用到许多外部的js,css文件,那么问题来了,怎样才能一次性引入? 通过js便可实现 走码: //创建一个init.js文件 var jsUrls = "js/j ...

  2. 每天一点css3聚沙成塔(一):transition

    transition 语法: transition:[ transition-property ] || [ transition-duration ] || [ transition-timing- ...

  3. 关于url拼接传参数和利用view的字典传参数时,模板获取数据的方式问题

    url = "{% url 'dashboard:internship-theme-stat' %}?teacher_name="+teacher_name+"& ...

  4. [C入门 - 游戏编程系列] 贪吃蛇篇(一) - 世界定义

    每个游戏都有一个很明确的目的或者说游戏主题,贪吃蛇的目的很明确:蛇找到并吃掉食物.只有目的是很无聊的,算不上一个好游戏.所以设计者增加了创意:1. 吃掉食物后蛇会增长:2. 吃掉食物后分数会增加.有些 ...

  5. 【转】WPF - 第三方控件

    WPF - 第三方控件 目前第三方控件在网上形成巨大的共享资源,其中包括收费的也有免费的,有开源的也有不开源的,合理的使用第三方控件将使项目组的工作事半功倍.比如项目中有些复杂的业务逻辑.有些绚丽的效 ...

  6. 如果设置Keil从C代码编译出来的hex文件地址从0x8000开始

    和MON51的设置一样,这样作:1.把Startup.a51拷贝到工程目录加入工程,修改125行的      CSEG    AT      0  为   CSEG    AT      0X8000 ...

  7. jQuery之Jcrop

    头像裁剪是一个经常用到的功能,实现原理也较为简单,就是在本地选择好所需裁剪图片的坐标,将坐标发送到服务器,由服务器执行图片裁剪操作. jQuery插件Jcrop提供了强大的图片裁剪坐标选择插件.一下来 ...

  8. Search Insert Position 解答

    Question Given a sorted array and a target value, return the index if the target is found. If not, r ...

  9. 内存映射与DMA

    1.mmap系统调用的实现过程,该系统调用直接将设备内存映射到用户进程的地址空间. 2.用户空间内存如何映射到内核中(get_user_pages). 3.直接内存访问(DMA),他使得外设具有直接访 ...

  10. poj 1703(带权并查集)

    Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 31840   Accepted: ...