简体   繁体   English

如何在Android中生成小apk

[英]How to generate small apk in android

I have prepared Android Applications which contains 8 Activities. 我准备了包含8个活动的Android应用程序。 1st Default activity contains only two EditText to get username and password and 2 Buttons(one for login and other for new user registration) In registration activity there are 6 EditText and 6 TextView. 第一个默认活动仅包含两个用于获取用户名和密码的EditText和两个按钮(一个用于登录,另一个用于新用户注册)。在注册活动中,有6个EditText和6个TextView。 and in remaining all activity there is only one TextView with Small line is written, 在剩下的所有活动中,只编写了一个带有Small行的TextView,

But when I check size of APK file it shows me 411 KB. 但是,当我检查APK文件的大小时,显示为411 KB。 How can I generate small APK. 如何生成小APK。

Thanks in Advance 提前致谢

411KB is already pretty small for an android application. 对于Android应用程序而言, 411KB已经很小。

Most are at least 1 or 2 megabytes. 大多数至少为1或2兆字节。 I don't think you need to worry about the size of your application as it stands at the moment. 我认为您现在无需担心应用程序的大小。

However, if you really want to reduce the size of your APK, you could make sure to delete any redundant resources, or (as Richard Le Mesurier said) try using ProGuard . 但是,如果您确实想减小APK的大小,则可以确保删除任何冗余资源,或者(如Richard Le Mesurier所述)尝试使用ProGuard

To add to what Tom Leese said in his answer , you could run ProGuard on your build. 要添加Tom Leese在回答中所说的内容,您可以在构建中运行ProGuard。

That will result in an optimally small APK. 这将导致最佳的APK。

Edit your project.properties file and look for the line that says: 编辑您的project.properties文件,然后查找显示以下内容的行:

# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

When you run an external signed build using the Android Tools menu, ProGuard will shrink your app. 当您使用Android工具菜单运行外部签名构建时,ProGuard会缩小您的应用程序。

More info on ProGuard here - http://proguard.sourceforge.net/index.html# 有关ProGuard的更多信息,请点击此处-http: //proguard.sourceforge.net/index.html#

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM