Huge Difference Between APK Release - Signed APK Size

I found two possible ways to create an APK release

  • Defining product attributes and Config signatures, as shown below in the module build.gradle file, and then clicking the Run button (betaRelease Config)

    android { signingConfigs { my_alias { keyAlias 'my_alias' keyPassword '*******' storeFile file('*******') storePassword '******' } } compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { minSdkVersion 16 targetSdkVersion 22 versionCode 9 versionName "0.2" resConfigs "en","hi","te" multiDexEnabled true } buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.my_alias } debug { minifyEnabled false } } productFlavors { alpha { applicationId = "***************" resValue 'string', 'app_name', '**********' resValue 'string', 'instabug_app_id','*******************' manifestPlaceholders = [onesignal_app_id : "*******************", onesignal_google_project_number: "************"] } beta { applicationId = "***************" resValue 'string', 'app_name', '**********' resValue 'string', 'instabug_app_id','*******************' manifestPlaceholders = [onesignal_app_id : "*******************", onesignal_google_project_number: "************"] } } aaptOptions { additionalParameters "--no-version-vectors" } } 
  • Using the Generate Signed APK option on the Build menu in Android Studio

There is a huge difference with the first APK with 14.5 MB, and the second with 22.5 MB. Using the APK Analyzer, I saw that the second duplicates the drawings in the res folder, as shown below. The smaller release of the APK (14.5 MB) works well on all devices.

enter image description here enter image description here

  • Why do I need more? Can I download the regular version of the APK to the play store?

  • Is there any configuration to build to avoid duplicate drawings?

+5
source share
2 answers

I will try to answer this question based on my observations.

1.

Why do I need more? Can I download the regular version of the APK to the play store?

When you release apk by clicking the "Run" button, you will target a specific device (emulator or USB device), and you will allocate resources only for this purpose. This is why you have a smaller .apk file.

If you want to deploy and adjust the entire density of devices, you should use the "Generate Signed APK" option to provide resources (such as images) for all devices.

The small version of the APK (14.5 MB) works well on all devices.

I think because images are scaled to fit on the screen. But you lose quality in the images this way.

2.

Is there any configuration to avoid duplicate links?

Providing resource instructions, it is written that:

Layout direction of your application. ldrtl means "layout-direction-right-to-left". ldltr means "layout-direction-left-to-right" and is an implicit default value.

All this means that you do not have duplicate drawings, but now they are in the corresponding directories.

+2
source

Android adds several files to the assembly on its own ... it also merges several manifest files into the assembly so that it can be recognized as a release build. You can get a better idea of ​​what and how big things are added to your apk by analyzing your regular build of apk and apk apk using the APK analyzer tool in studio 2.2 +

Keeping minifyEnabled true will help you reduce the apk file size if you need it too!

0
source

Source: https://habr.com/ru/post/1263590/


All Articles