How To Reduce Android App Size During Development?

  Mohit Singh    September 3, 2020    24

 

The rising desires of users motivates developers to incorporate more things in application. Similarly it results into an increased application size. The large size applications frequently transform into storage hoggers in our smartphones causing them to operate slow or hang in the middle of a significant work. As per Google, if the size of an application is more than 150MB, in chances of installation decrease by 30%. The install conversion rate can drop by 1% if size increases by 6 MB. 

Many technology specialists out there work on creating small applications or tools which can reduce the size of an application. Android App Bundle is a publishing tool through which users don’t have to re-download things that are already there in other applications over play Store. This platform is said to decrease the size of an application by 35%. Let us explore other ways to reduce android app size during app development lifecycle.

Also know- 9 Effective Tips To Reduce Mobile App Development Cost.

How to reduce android app size?

1. Image optimization- 

You can conveniently reduce image size without reducing the resolution. For example, .jpg and .png pictures can be changed over to .webp web picture format to downsize applications without compromising the quality. The .webp format offers lossy compression like .jpg and transparency like .png. There are many tools available for such conversion. Tools like guetzli and packjpg suit .jpg file compression best while pngcrush and zopflipng befit .png files. Designers can implement vector graphics to make simple resolution-independent images that don’t crib for space. These are available in Android as VectorDrawable objects and allow a 100-byte file to generate images sharp and screen-sized.

android {
     defaultConfig {
         vectorDrawables.useSupportLibrary true
     }
 }

It is already known that a few images can do without static resources. The framework is enough to draw such images dynamically at runtime. Utilizing Vector Drawables objects is a brilliant idea when small size applications are to be developed. They can survive on minimal space within the APK file and create pictures compliant with the rules of material design. However, there could be a tussle with regards to CPU and RAM usage as complex objects will in general slow them down.

Also, using the Draw 9-patch tool can saves space. This is a WYSIWYG image editor and probably the coolest approaches to cut image size. The tool lets you make bitmap images that can auto-resize to fit the different screen sizes of various mobile devices. Select parts within the image can be scaled vertically or horizontally depending on the indicators drawn in it.

Another way is to use the aapt tool to crunch .png images, the resources of these are available in res/drawable/. The compression is lossless. For example, a true-color .png image  which needn’t bother with more than 256 colors can be changed over to a color palette enabled 8-bit one. The latter retains the quality yet sheds the size.

Developers must remember that the aapt tool would not compress .png files in the asset/folder. Additionally, it won’t have the option to optimize any image that uses more than 256 colors. Additionally, it may puff up .png files which have just been shrunk. This disadvantage can be avoided by using the cruncherEnabled flag in Gradle as such:

aaptOptions {
    cruncherEnabled = false
}

2. Elimination of redundant code: 

Excess code is an unnecessary code which is composed to recompute a value that has already been calculated or might be a code which has been executed but leaves no impact on the functionality of an application. The definition itself shows that it is useless which needs to be avoided from the framework so to make it without load. Such methods or classes can’t do anything to the application, rather, they are simply in place to increase the size of the application. Elimination of such code would help you more.

3. Dead Code Elimination-

The size of the APK file is proportionate to the load speed of your application, the memory it uses and the power it requires. As such, any defective code kept only for the sake of keeping will just add to the bulk. Much like the removal of excess codes, dead code elimination is important for your application to remain energized at any time. The process has zero effect on the functionality of the application, because such codes aren’t a part of it in any case. However, removing them upgrades the quality of the source code and reduces the need to maintain code size. Also, occurrence of bugs is prevented, in this manner introducing a bug free healthy app.

4. Minimized use of Resources from Libraries-

Generally external libraries are used while developing android app. And hence usability and versatility can be delivered to the most extreme.

The basic ones are Google Play Services, which is used to recover auto translations of application text and Android Support Library, which is used to improve the user experience on dated devices. Such libraries are also designed for servers or desktops and come with loads of methods and objects that don’t serve the application any purpose. However, you can edit  the files and retain just those parts which your application requires. Obviously, for this to occur, you’d need modification permissions. On the other hand, you can also use a mobile friendly library for specific functionalities.

5. Support for Specific Screen Densities-

Consider those Android-enabled devices that blare around the world. Think about the platform supporting them. Truly, Android is easy with a huge amount of mobile devices with varied screen densities, including ldpi, tvdpi, mdpi, hdpi, xhdpi, xxhdpi, and xxxhdpi. But, you don’t need all of them for your application. You can generally manage without exporting rasterized assets for each one of them. 

How you can do it? 

Make an overview to decide the percentage of users with devices that have specific densities. If this rate is not significant, why bother bundling each one of those densities in your application? All things considered, if you do exclude them, Android would step in automatically scaling the resources meant for different densities.

android {
    splits {
        density {
            enabled true
                }
    }
}

6. Avoid Enumerations-

Enums are tricky. A single one can add anywhere in the range of 1.0 to 1.4 KB to the classes.dex file of an application. These can accumulate at ninja speed, particularly if there are shared libraries or complex systems. This is the reason it is smarter to avoid enumerations. How? – By using ProGuard and the @IntDef annotation to convert enumerations into integers. Consequently, you would have a decreased size with all the goodness of enums intact.

7. Use APK Size Analyzer- 

APK Analyzer can help you with a lot of data about size of the APK. On the highest point of the screen, you will have the option to see the Raw File Size which is the APK on-disk size. The Download size shows that how much data will be used to download your application by considering account compression applied by the Play Store. APK size analyser can be effectively downloaded from plugin marketplace over Android Studio. Over the analysis report, you will find folders and files listed in descending order according to their size. You can easily find the things taking a large space through this feature. It is also controlled with Comparison feature through which you can see the size difference between old and new builds.

8. Downloadable fonts- 

The vast majority of the applications over play store use same fonts. Hence most of them are already contained by the App bundle. When a user runs various applications containing same fonts on one device, duplicacy is made. Google identified the situation and presented Downloadable fonts present in its Support library. Presently, APIs don’t need to bundle files, it can simply request fonts.

9. Offer multiple APKs- 

Sometimes users wonder if there was any approach to download just the parts of an application which are useful for them but it is not possible to download half of an APK. As a solution, you can upload your application over Google Play through Android App Bundles with the goal that Google can enable optimized APKs according to the device configuration. You can separate one onto various APKs, as a result, users would just receive APKs that are valuable for them according to their device configuration.

Wrap up-

Reducing the app size results in user-friendliness of an application. Apps having large sizes fail to stand up in market until they offer the unique most platform. Hence following the above guidelines will surely help you to reduce the app size and make it successful.

If you are facing any difficulty to reduce the app size, consult with solace team. Experts at Solace are well proficient to give you the best solution with new trends and technologies. You can also hire android developers to develop an app with reduced size.


 Article keywords:
android apps, android developer, applications, technology

 


 Share this article: 
Print Digg StumbleUpon del.icio.us Facebook Yahoo! Buzz Twitter Google Bookmarks LinkedIn MySpace Orkut PDF Scoopeo Viadeo Add to favorites
      

© Copyright - Articles XP