How to Reduce Android App Size During Development?
The rising expectations of the users lead developers to integrate more and more things resulting into an increased app size. The large size applications often turn into storage-hoggers in our smartphones making them operate slow sometimes or hang in between an important work. One cannot stay with or without them which is why they often remain in a love-hate relationship with the users. Though, mobile devices now come up with large storage spaces ranging from 16GB to 256GB. Still, our dream of housing all the useful and entertaining apps in them cannot be turned into reality. In the realm of Android mobile app development, size is the major most issue.
According to Google, if the size of an app is more than 150MB then installation chances reduce by 30%. The install conversion rate can drop by 1% if size grows by 6 MB. You might wonder,
Is there any way to serve as it is with reduced size?
A lot of tech giants out there work on creating small apps or tools which can reduce the size of an app. Android App Bundle is a publishing platform through which users do not have to re-download items that are already there in other applications over Play Store. This platform is said to reduce the size of an app by 35%. Through this, users would be able to save much of the storage for other useful applications.
An Android App Bundle is relatively new format of uploading which includes compiled codes and resources but at the same time differing in Signing to Google Play and APK Generation. App Bundles are basically signed binaries organizing the code and other resources into modules. Each module can be generated as separate APK. Google Play uses the app bundle to generate different APKs that are served to users, such as the base APK, dynamic feature APKs, configuration APKs and multi-APKs.
App bundle cannot be the only way though, which is why we are here coming up with more ways to further reduce the size of your application and hence encouraging users to use it.
1. Image optimization: It is most likely for you to choose best and high-resolution images for your app to appeal users and back the efforts of your designer. Because only good images can complement good designing. If you have the best design and pixelate images all over then all your designing efforts might go in vain. Images captured from good cameras are generally high resolution. We can reduce the image size by diluting the resolution for example, if you do not want to compromise on quality, you can convert .jpg or .png images to .webp. There are separate tools which can assist you for the same. For example, for .jpg compression, you have guetzli and packjpg where as zopflipng and more such tools are useful for png conversion.
Apart from this, you can ask your designers to implement vector graphics for the development of simple resolution-independent images. You can also use Vector Drawable objects which are capable of drawing required images dynamically at runtime. Draw 9 patch tool is another editor which lets you create bitmap images fitting various screen sizes and devices. It currently serves as one of the cool ways to edit images without hurting quality.
2. Deleting dead code: The mobile app developers often comment codes as a shortcut to eliminate anything unnecessary with the hope that it might be useful in future though, most of that code is useless for life. You need to remember that the load on your app and memory it would us is directly proportional to the size of APK file. Any kind of code that does not have to do anything with the existing functionalities of an app just increases load on it. To keep your app free of load and always energized, get rid of such codes. If such codes do not form any part of the functionality then there would be no impact over the app whether you keep it or delete it. It also reduces the chances of bugs and improves the overall performance of the app by reducing its size and increasing speed.
3. Elimination of redundant code: Redundant code is an unnecessary code which is written to recompute a value that has already been calculated or may be a code which has been executed but leaves no impact on the functionality of an application. The definition itself indicates that it is something useless which needs to be eliminated from the system so to make it load-free. Such methods or classes cannot do anything to the app, instead, they are just in place to increase the size of the app. Elimination of such code would help you a lot.
4. Do not bother about all screen densities: Developers are generally asked to make such app which runs well on all the devices due to which they have to put extra efforts in taking all screen densities in picture like ldpi, mdpi, tvdpi etc. Though, all of them are hardly needed. Simply, do a survey to find out the percentage of users having devices with specific densities. Do not bother about the screen density with insignificant figures. In most of the cases, Android would itself enter automatically to scale the available resources associated with other densities.
5. Remove unused resources: Android Studio comes up with a tool called lint which is the static code analyser. It is capable of detecting the unused resources and prints below message:
res/layout/preferences.xml: Warning: The resource R.layout.preferences appears to be unused [UnusedResources]
Unused resource fall in place while doing a lot of things like adding a library to the code. Gradle is another tool for the automatic removal of resources or classes. It comes to action when you enable code shrinking and allow it in the file called build.gradle within the app. Followed by Gradle, ProGuard would be the tool to remove unused code.
6. Minimize the use of external libraries: Developers often make use of external libraries for some functions such as Android supply library is used to improve the UX in the dated devices whereas Google Play Services for auto-translation of app content. Since, these are built for servers or desktops as well, they come up with a lot of objects and methods which are not useful for app. You cannot eliminate the unnecessary code as well because to do that, you will need permission. So as an alternative, go for the mobile friendly libraries specifically so that you do not have to use any heavy modules.
7. Avoid enums: Enumerations are known to accumulate at high speed when the system of complex or working on shared libraries, so you need to get rid of them. You can use ProGaurd to convert these enums into integers and as a result, you will get an app with reduced size.
8. Use APK Size Anlyzer: APK Analyzer can help you a lot with much of the information about size of the APK. On the top of the screen, you will be able to see the Raw File Size which is the APK on-disk size. The Download size shows an estimate of how much data will used to download your app by taking into account compression applied by the Play Store. APK size analyser can be easily downloaded from plugin marketplace over Android Studio. Over the analysis report, you will find folders and files listed in descending order on the basis of their size. You can easily find of the things taking most of the space through this feature. It is also powered with Comparison feature through which you can see the size difference between old and new builds.
9. Downloadable fonts: Most of the applications over Play Store use same fonts so a lot of them are already contained by the App bundle. When a user runs multiple apps containing same fonts on one device, duplicacy is created. Google recognized the situation and introduced Downloadable fonts present in its Support library. Now, APIs do not have to bundle files, it can just request fonts.
10. Offer multiple APKs: Sometimes users wonder if there was any way to download only the parts of an app which are useful for them but it is not possible to download half of an APK unfortunately. As a solution, you can upload your app over Google Play via Android App Bundles so that Google can enable optimized APKs as per the device configuration. You can also divide one onto multiple APKs, as a result, users would only receive APKs that are useful for them as per their device configuration.
Why is it required to reduce the App size?
A. Low device storage space: You might wonder it is not an era of 8 or 16 GB we are living in, we now have 64GB, 128GB, even 256GB of hard disk space in our phones. Still, are you running out of space today? Most of the people would say “Yes”. This is because we have some of the amazing applications and games hitting the market every now and then. Even after getting unlimited alerts over Low storage, we cannot control ourselves from being engaged on such platforms. So, if your app size is high, it would not be able to house in the user’s phone for a long time.
B. Low conversion rates: It has been found in a study that for every 6 MB increase to an APK’s size, we see a decrease in the install conversion rate of 1%. If the user will see a huge figure in GBs, he/she would not likely to install your app on their already piled up phone. Even if they install, they will keep it only when it has a great value, maybe equal to Whatsapp or Uber. Around 70% of people consider size of an application while downloading it. Data cost is not a big factor nowadays but yes, if the same affect their phone storage or its overall speed, then yes, you will most likely lose on things. The download figures might also vary location to locations. For example, according to a report published on Medium, “there is a 10MB decrease seen in APK size has a larger impact in India and Brazil than Germany, USA and Japan. The removal of 10MB from an app’s APK size in emerging markets correlates with an increase in install conversion rate by ~2.5%.”
C. Low internet speed: Slow downloading irritates users a lot which is why they can give up on you. High size applications generally take time to get downloaded and installed. It is not necessary that users always remain in high speed WIFI area while downloading any app. Some of the users do not even have access to Wifi, they operate on mobile data which is hard to rely on in the case of downloading something of considerable size like heavy games. May be, the market buzz, PUBG! Lite apps come to the rescue at this time which are the lighter versions of heavy apps. For example, we have Uber Lite which is simpler version of Uber capable of operating at the low network spaces and on any Android phone. It takes a space of less than 5MB. Its not like it is any lesser than Uber. Uber Lite does contain all the major features.
For all the obvious reasons, you need to come up with an app acquiring low disk space. It increases the user friendliness of an application to a great extent. Apps with huge sizes fail to perform in the market until they offer the unique most platform. We agree on the maturity of disk space, but we cannot deny over maturity of mobile app spaces. With new innovations coming on board, developers keep on adding new features to serve and attract users. However, as an increasing number of features also lead to more SDKs, higher resolution images, better graphics and hence the larger APK sizes.