如何在android中生成小apk

[英]How to generate small apk in android


I have prepared Android Applications which contains 8 Activities. 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. and in remaining all activity there is only one TextView with Small line is written,

我准備了包含8個活動的Android應用程序。第一個默認活動只包含兩個EditText來獲取用戶名和密碼以及兩個按鈕(一個用於登錄,另一個用於新用戶注冊)在注冊活動中有6個EditText和6個TextView。並且在剩下的所有活動中只有一個帶有小行的TextView被寫入,

But when I check size of APK file it shows me 411 KB. How can I generate small APK.

但是,當我檢查APK文件的大小時,它顯示我411 KB。我怎樣才能生成小APK。

Thanks in Advance

提前致謝

2 个解决方案

#1


3  

411KB is already pretty small for an android application.

對於Android應用程序,411KB已經相當小了。

Most are at least 1 or 2 megabytes. I don't think you need to worry about the size of your application as it stands at the moment.

大多數是至少1或2兆字節。我認為您不必擔心應用程序的大小。

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。

#2


2  

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#


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2014/03/05/bfb2aff2358ae4de2b3e902890dfc408.html



 
  © 2014-2022 ITdaan.com 联系我们: