Android Studio:构建 APK 与运行 APK 之间的大小差异 [英] Android Studio: Difference in size between Build APK vs Run APK

查看:125
本文介绍了Android Studio:构建 APK 与运行 APK 之间的大小差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到使用这 2 个选项生成的 apk 之间的大小不同.

I have noticed a difference in size between the apk generated with these 2 options.

为什么会这样?

使用构建 -> 构建 APK 选项:

MyProject\app\build\outputs\apk\app-debug.apk(大小 2.997 KB)

MyProject\app\build\outputs\apk\app-debug.apk (Size 2.997 KB)

使用运行应用选项:

MyProject\app\build\outputs\apk\app-debug.apk(大小 3.300 KB)

MyProject\app\build\outputs\apk\app-debug.apk (Size 3.300 KB)

谢谢.

推荐答案

如果将这个问题作为 issue 提交给 Android Studio 团队可能会得到更好的回答.我的猜测是您在 Android Studio (AS) 中使用了 Instant Run.这可以解释更大的尺寸,因为 Instant Run 会为更改的代码生成代理类.

This would probably be better answered if posed as an issue to the Android Studio team. My guess is that you're using Instant Run inside Android Studio (AS). This would explain the larger size since Instant Run generates proxy classes for changed code.

编辑 Run 配置以使用 gradle build 构建,您应该能够删除额外的代码......但这将带来更大的构建/部署时间...如果调试版本的大小对您来说真的很重要,那么可以,但对于大多数人来说,这将破坏 Android 团队最近为提高速度而对 DSL 所做的所有改进

Edit the Run configuration to build using gradle build and you should be able to remove the extra code... But this WILL come with a much larger build/deploy time... If size of a debug build is really important to you then OK but for most this will ruin all the improvements the Android team has made to the DSL recently to improve speed

这篇关于Android Studio:构建 APK 与运行 APK 之间的大小差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆