问题描述
我在 android 中遇到了应用大小问题.
I am facing a problem with app size in android.
场景是,
我在 Android Studio 2.0 中开发了我的 android 应用程序,apk 的大小为 23 MB.
I developed my android app in Android Studio 2.0 and the size of apk was 23 MB.
在那之后,我将我的 IDE 升级到了 android studio 2.2,并且几乎没有修改代码,apk 的大小就增加到了 51 MB.
After that, I upgraded my IDE to android studio 2.2 and with little code modification the size of apk boosted to 51 MB.
我尝试使用 prorogued 和 Lint 但没有优势.
I tried with prorogued and Lint but no advantage.
谁能帮我解决这个问题.
Can Someone help me to tackle the issue.
推荐答案
1) 将所有的 Image,Icons 替换为 vector drawable
1) Replace all of Images,Icons with vector drawable
2) 像下面这样开启专业防护转到 build.gradleapp 级别
2) Turn on pro guard like followinggoto build.gradleapp level
并放置这些行
**shrinkResources 为真
**shrinkResources true
minifyEnabled true**
minifyEnabled true**
3) 删除未使用的类、drawable 以及方法和字符串并使用 LINT 的私有方法分析器,减少方法数量
3) Remove unused classes,drawable and methods and stringsand use LINT's private method analyser which reduces method count
4) 在 android studio 2.2 及更高版本中,他们在 Build 菜单中添加了 apk 分析器 工具.用它来分析APk
4) In android studio 2.2 and above they have added apk analyser tool in Build menu. Use that to analyse APk
5) 如果应用程序大小超过 100mb,则使用称为 split apk 的功能.有两种拆分apk的方法ABI 和密度拆分
5) if app size goes beyond 100mb use feature called split apk.there are two methods of spliting apkABI and Density Splits
这篇关于减少apk大小android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!