Reputation: 350
I found two possible ways to generate a release APK
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"
}
}
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.
Why do I need the bigger one? Can I upload the normal release APK into play store ?
Is there any configuration to build avoiding the duplicate drawables?
Upvotes: 6
Views: 2200
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
Reputation: 31
I will try to answer this question, based on my observations.
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.
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