The Best Tips to Reduce Android App Size.

The Best Tips to Reduce Android App Size

Users often tend to avoid downloading apps that come in too large a size, especially in emerging markets in which emerging devices connect to often problematic 2G and 3G networks or worn on pay-by-the-byte plans. Following are a few essential tips on how you can reduce the download size of your application which enables users to download your app. You may get this done by hiring a custom android app development company in India.

Best Tips to Reduce Android App Size

Understand APK structure:

Before you get on with reducing the size of your, you first need to understand the structure of the APK of an application. An APK file consists of a ZIP archive that consists of the files that comprise your app. These files contain Java class files, resource files, and a file with compiled resources.

An APK consists of the following directories:

  • META-INF/- the CERT.SF and CERT.RSA signature files, the MANIFEST.MF manifest file.
  • assets/ – the assets of the application that the app can retrieve using an AssetManager object.
  • Res/ – the compiled code that stands specific to the software layer of a processor. The directory has a subdirectory for every platform type, like armeabi, armeabi-v7a, arm64-v8a, x86, x86_64, and mips.

An APK also includes the following files among which only AndroidManifest.xml is mandatory:

  • resources.arsc- the XML content from all the configurations of the res/values/ folder. The packaging tool extracts this XML content, compiles it into a binary form and keeps the content in archive. This content consists of language strings and styles, as well as paths to content that is not directly a part of the resources.arsc file.
  • classes.dex- the classes compiled in the DEX file format that the Dalvik/ART virtual machine understands.
  • AndroidManifest.xml- the core Android manifest file. This file lists the name, version, access rights, and referenced library files of the app and the file uses Android’s binary XML format.

Reduce the resource count and size:

  • The size of the APK of your app has an influence on the loading time of your app, the memory use, and the power consumption.
  • You can specifically remove resources that your app does not use anymore. You can use scalable Drawable objects in place of image files.
1. Upload your app with Android App Bundles: 

The easiest way to immediately reduce the size of your app when publishing it on Google Play is to upload your application as an Android App Bundle.

The Android App Bundle is a new upload format that consists if all the compiled codes of your app and all the resources. It defers generation of APK and Google Play sign in.

The new app serving model of Google Play is called Dynamic Deliver. This model uses your app bundle for generating and serving optimized APKs for the device configuration of each user. Hence, they download only the code and resources that they require for running your app.

You will not have to build or manage multiple APKs for supporting different types of devices and users can easily get smaller and more optimized app downloads.

Note that Google Play enforces a compressed download size restriction of 150 MB or less for the applications that have been published via app bundles. You need to apply the guidelines mentioned in order to reduce the download size of your app as much as is possible.

2. Use the Android Size Analyzer:

Download the Android Size Analyzer plugin via the plugin marketplace in Android Studio.
To open the plugin marketplace and install the plug in, go to file and select the settings option. Go to the plugins section in the left panel and click on the marketplace tab. Search for the “Android Size Analyzer” plugin and click on the install button for the Analyzer plugin.

After you are done with installing, run an app-size analysis on your current project by going to the Analyze option and selecting the Analyze App Size option from the menu bar. Now, a tool window will appear after the app size analysis is done. The window will show recommendations on how you can reduce the size of your app.

3. Use the analyzer from the command line:

Download the latest version of the Android Size Analyzer either as a TAR file or a Zip file from GitHub. After you have extracted the archive, run the size-analyzer script or the size-analyzer.bat script on your Android project and Android App Bundle Using any one of the following two commands-

./size-analyzer check-bundle <path-to-aab>

Or,

./size-analyzer check-project <path-to-project-directory>

4. Remove the unused resources:

The lint tool is a static code analyzer included in Android Studio. It detects the resources in your res/ folder that your code does not refer to. When the Lint tool will discover an unused resource in your app, it prints a message that looks as follows:

Res/layout/preferences.xml : Warning : The resource R.layout.preferences appears to be unused [Unused Resources]

Libraries which add to your code may include unused resources. Gradle automatically removes resources on your behalf when you will enable the shrinkResources in the build.gradle file of your application.

For using shrinkRresources you will have to enable code shrinking. In the course of the build process, R8 will first remove unused codes and then the Android Gradle plugin will remove the unused resources.

Read Also: Android or iOS App Development: Which is Best for Your Business?

5. Minimize the resource usage from the libraries:

While you develop an Android app, you generally use external libraries for improving the usability, functionality and versatility of your app. If a library was designed for a server or desktop, it can consist multiple objects and methods that your app does not require.

You can edit the files in the libraries if the license allows you to modify the library, for including only the parts of the library your app will need. You may also use an alternative, mobile-friendly library for adding specific functionalities to your app.

6. Use drawable objects:

Some images will not need a static image resource. The framework can draw the image at runtime automatically instead. Drawable objects can consume only a tiny bit of space in your APK. Also, XML Drawable objects produce monochromatic images in compliance with material design guidelines.

7. Reusing resources:

You may include a separate resource for variations of an image, like for example, tinted, shaded, or rotated versions of the same image. You can reuse the same set of resources customizing them as required at runtime.

You may also omit the resources that are just a rotated equivalent of another resource.

8. Render from Code:

You can also reduce the size of your APK by rendering your images. Procedural rendering frees up space because you will no longer be able to store an image file in your APK.

Read Also: Native, Hybrid or Web App- Which App is Ideal for Your Business

Conclusion:

There are several other methods to do it, but the main ones have been mentioned above. If you are not doing it yourself, a Mobile app development company in India will be able to help you with this.

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest

Join Our Newsletter
Subscribe to our email newsletter today to receive updates on the latest news, and special offers!
Thank you for subscribing.You’ll now receive our latest blogs, news releases and whitepapers. Please check your email.
×
×
WordPress Popup Plugin