Creating Multiple APK Files of Android App

How to Create Multiple APK File for Android Application: New Android devices are continuously being introduced with different CPU architectures and different screen densities. This results in the increase in apk size, as it contains resources for every device. Why users need to download apk containing resources of other devices that are useless for them and making their phone storage full. So, developers need to create multiple or splitting the apk file which is smaller in size containing only the essential resources, fitting all segment devices available.

Developers can generate the multiple numbers of apks for a single application, by splitting a single apk into multiple apks, where each apk is specific for specific devices. Multiple apks generated contain resources for different screen densities device specifically and different CPU architecture. The main goal of splitting apk is to reduce apk size that can’t be achieved through reduction of app resources of single apk file.

How to Create Multiple APK File for Android Application

How to Create Multiple APK File for Android Application

It is true that these days’ devices are coming with larger spaces but at the same time there are too many devices available are having very low memory. So, the targeted devices are very large. Hence, developers can’t lose some group of devices or reduce resources size used in the application.

So, developers need to split their apk file into multiple files. Follow the given guide on how to create multiple APK file for Android application.

For the generation of screen density specific apk files, developers need to generate files in all the screen densities available. Generally, there is six set of densities-ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi.

Generating one APK File for Multiple Screen Densities

Paste the following block of code in your Gradle file and click build apk.

android {
…….
…….
splits {
density {
enable true
exclude “mdpi”, “xxxhdpi”
compatibleScreens ‘small’, ‘normal’, ‘large’, ‘xlarge’
}
}
}

This code will generate apk for all set of densities excluding mdpi and xxxhdpi with universal app. Universal apk is compatible with every available devices and upcoming devices. Let’s take a look at different keywords of this code:
1. Exclude: By this keyword, developers add a list of screen densities for which they do not want their gradle to make apk.
2. Include: With this, developers add a list of densities that they want their gradle to make apk for. To use this keyword, reset must be added to the code then use include.
3. Reset: It is used to clear all the default list of screen densities, use only if include is used.
4. Density: This is used to build multiple apk based on screen density
5. CompatibleScreen: This is to specify a list of compatible screen sizes, if developers are building apk for all devices, they use compatibleScreens ‘small’, ‘normal’, ‘large’, ‘xlarge’ or all at once.

Generating Multiple apks for Specific Types of abi

We can generate a specific apk file for a set of Abi armeabi, armeabi-v7a, arm64-v8a, x86, x86_64, mips, mips64.
Write the following block of code in gradle file and click on build apk.

android {

splits {
abi {
enable true
reset()
include “x86”, “mips”
universalApk false

}
}
}

This code will generate apk for x86 and MIPS. Universal Apk is set false by default for abi so developers need to set it true.

Generating Combined apk for Screen Density and CPU Architecture

Copy the following code in the app level gradle file and click on build apk.
android {
…..

splits {
density {
enable true
reset()
include “mdpi”, “xhdpi”
}
abi {
enable true
reset()
include “mips64”, “mips”
}
}
}
This will generate four combined apk for mdpi-mips64, mdpi-mips, xhdpi-mips64 and xhdpi-mips.

Rules for Uploading Multiple apk Files on Google Play Store:

1. Should contain a distinct version code for each apk.
2. Should contain identical package name for each apk.

How to create apk with Distinct Version Code?

Write the following code in the app level gradle file and click on build apk to generate apk with different version code.
ext.densityCodes = [‘mdpi’: 1, ‘hdpi’: 2, ‘xhdpi’: 3]

import com.android.build.OutputFile
android {
…..

android.applicationVariants.all { variant ->

variant.outputs.each { output ->

def baseDensityVersionCode =

project.ext.densityCodes.get(output.getFilter(OutputFile.DENSITY))

if (baseDensityVersionCode != null) {
output.versionCodeOverride =
baseDensityVersionCode * 1000 + variant.versionCode
}
}}}

You are now ready to upload multiple apks of your application. Hopefully after reading this article you’ll be able to reduce your apk size by splitting into multiple files.

Let us know in the comments area below if you have any question regarding How to Create Multiple APK File for Android Application.

Subscribe to our newsletter
Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time

Leave A Reply

Your email address will not be published.

android 1, android, android studio, android device manager, android pie, android games, android one, android emulator, android versions, android emulator for pc, android apps, android app development, android authority, android apk, android arsenal, android apps on pc, android auto, android activity lifecycle, android app download, android architecture, android codes, android color codes, android central, android cdc driver, android car stereo, android course, android camera, android omponents, android box, android beta, android best games, android beam, android backup, android backup to pc, android basics, android games, android games apk, android games free download, android go, android gamer, android games 2018, android games on pc, android glide, android game development, android emulator online, android emulator download, android emulator for mac, android emulator for windows 10, android file transfer, android file host, android framework, android flash tool, android firmware, android hacking tools, android hd wallpapers, android hard reset, android heavy games, android data recovery, android keyboard, android kitkat, android keyboard apk, android keylogger, android imei check, android multi tools, android manager, android material design, android mobile games, android modded games, android latest version, android lollipop, android nougat, android oreo, android pie, android play store, android pc suite, android pie update, android police, android programming, android questions, android ringtones, android root, android root apk, android root apps, android tv box, android themes, android tools, android wallpapers, android wallpapers hd, android usb driver, android ui design, android update 8.0, android update 9.0, android studio, android sdk manager, android secret codes, android vidmate, android youtube downloader, android youtube downloader apk, android youtube background play, android zapya