How to Create Multiple APK Files For Android Application?

Nithya Nataraj
2 min readSep 22, 2021

--

In Android, making a single apk compatible with all devices, increases the apk size, as it has resources for every device. Why make our users download apk that contain device-specific useless resources who are having lower memory devices. Now we got the solution i.e. creating multiple apks from the same application or apk for a specific device. Generating the multiple numbers of apks for a single application, by splitting a single apk into multiple apks, where each apk is specific for a particular device. Multiple apk is mainly used to generate specific apks for different screen densities and different CPU architecture.

How Does the apk Size Reduce?

It does not compress the app size by compressing the resources used within the app. It makes new apks by including only the device compatible resources, and by excluding every other resource that is not compatible or unused for the specific device type. For example, if you are creating two apk one for hdpi and another for xdpi, then in the first apk, there will be no xdpi resources and similarly, in the second apk there will be no hdpi resources.

Implementation

  1. Navigate to the app-level Gradle file.

There are six sets of densities-ldpi, mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi for which we can generate screen density specific apk. Now, we will generate apk for all set of densities excluding mdpi and xxxhdpi with a universal apk.

Sync the Gradle file after adding the above code then click build apk. A notification will be popped up at the right-bottom of the android studio in order to see the located apk files. Otherwise, navigate to the location where all your android projects get saved, open your application then go to app > build > outputs > apk > debug.

By publishing your application with multiple APKs, you can:

  • Support different OpenGL texture compression formats with each APK.
  • Support different screen sizes and densities with each APK.
  • Support different device feature sets with each APK.
  • Support different platform versions with each APK.
  • Support different CPU architectures with each APK (such as for ARM or x86, when your app uses the Android NDK).
  • Optimize for entry-level devices such as those running Android (Go edition).

Thank you , Happy coding :)

--

--

Nithya Nataraj

Senior Software Engineer. 8+ years of experience in Android application development .