【发布时间】:2018-01-11 05:35:48
【问题描述】:
在构建 apk 文件后,我注意到我的应用程序大小为 2MB(原始文件大小)和 1.7MB(下载大小)。但是该应用程序非常简单,其大小为 classes.dex 单独占用大约 1.3MB 作为。
我使用 ProGuard 来混淆代码如下
android {
...
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
我也通过了链接Reduce Size of .apk file 和this 的堆栈溢出,但没有找到减少.apk 大小的方法。
gradle中添加的唯一依赖是:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:26.1.0'
}
我很确定这是由于支持库加载项。那么有人可以帮我找到减小/最小化这个尺寸的方法吗?
非常感谢任何见解。谢谢。
【问题讨论】:
-
添加
shrinkResources true -
感谢您的回复@Amiya,也使用了但忘记在代码中添加该行。正如我提到的,classes.dex 占用了更多空间,所以你知道有什么其他方法可以减小应用程序的大小吗?