Revanth Gopi
Revanth Gopi

Reputation: 350

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?

Upvotes: 6

Views: 2200

Answers (2)

Tatsuya
Tatsuya

Reputation: 379

Android adds few files to the build by itself...it also merges few manifest files to the build in order for it to be recognisable as a release build. You can get a better idea of exactly what and how large things are added to your apk , by analysing your normal build apk and release apk with the APK analyser tool in studio 2.2+

Keeping minifyEnabled true , would help you reduce your apk file size,if you need too!

Upvotes: 0

Kapski
Kapski

Reputation: 31

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.

Upvotes: 3

Related Questions