Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Huge Difference between Release APK - Signed APK size

I found two possible ways to generate a release APK

  1. Defining Product Flavours & Signing Config as 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"
    }
    }
    
  2. Using the Generate Signed APK Option from the Build menu in Android Studio

There is a huge difference here with the first APK with 14.5MB and the Second one giving 22.5MB. Using the APK Analyzer I could see that the second one is duplicating the drawables in the res folder as shown below. The smaller release APK (14.5MB one) is working well on all kind of devices.

enter image description here enter image description here

  1. Why do I need the bigger one? Can I upload the normal release APK into play store ?

  2. Is there any configuration to build avoiding the duplicate drawables?

like image 914
Revanth Gopi Avatar asked Jan 30 '17 15:01

Revanth Gopi


People also ask

What is the difference between APK size and download size?

Raw File Size represents the unzipped size of the entity on disk while Download Size represents the estimated compressed size of the entity as it would be delivered by Google Play. The % of Total Download Size indicates the percentage of the APK's total download size the entity represents.

Why does an APK need to be signed?

Application signing ensures that one application cannot access any other application except through well-defined IPC. When an application (APK file) is installed onto an Android device, the Package Manager verifies that the APK has been properly signed with the certificate included in that APK.


1 Answers

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

1.

Why do I need the bigger one? Can I upload the normal release APK into play store ?

When you release apk by clicking "Run" button you are targeting specific device (emulator or usb device) and you are genereting resources only for this target. That's why you have smaller .apk file.

If you want deploy and target to all density of devices you should use "Generate Signed APK" option to provide resources (ex. images) for all devices.

The smaller release APK (14.5MB one) is working well on all kind of devices.

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

2.

Is there any configuration to build avoiding the duplicate drawables?

in Providing Resources instruction is written that:

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

All of this means that you don't have duplicated drawables but now they are in proper directories.

like image 129
Kapski Avatar answered Nov 03 '22 11:11

Kapski