5 Smarter Ways to Reduce the Android Application Package Size
Android app marketplace has come of age, and since its beginning in 2012, the average Android app size has increased at least four times. As the internal device memory of most Android handsets increased in all these years along with the increase in random memory for swift performance, this increase in app size can be seen as normal and quite inevitable. But wouldn’t it be great if this memory space can be further optimized for better app performance? Yes, this is why keeping the app size smaller is essential.
How can you keep the app size smaller and lean without really hurting the performance and user experience? Well, there are several tested and tried ways to do it. Here we are going to explain some of the best measures to keep the size of Android apps smaller.
1. Run Proguard and use Vector Graphics
One of the most effective means to shrink the app code is to run the Proguard tool while compiling the code. This tool helps to shrink the code to a great extent. After running this tool always tests the app to ensure that it works properly. Many symbols are replaced by this tool to shrink the code size of the app and hence testing is necessary after running the tool. Basically, this tool detects all the unused snippets and scripts and renames several classes and fields to deliver a lean APK as well as lightweight code.
Using vector graphics is another way to reduce the APK size. Android 23.2 Support Library now supports vector graphics for all Android devices starting from the oldest ones. By converting the SVG files to vector graphics, Android Studio now can reduce the APK size significantly.
2. Use Android App Bundles
When working in Android projects app developers are more or less concerned about making the app compatible with as many devices as possible. This is only possible by providing optimised code and resources for various device attributes such as CPU architectures, languages, screen densities, etc. But this will also make the app heavier with tons of code meant for different device types that will mostly remain unused for each device user. So, while supporting maximum devices is essential, keeping the APK size smaller is equally crucial.
The new Android app bundle format will help you to shrink the APK size on an average of 35%. All you need to do is to upload the respective app as the .aab file, and the Google Play Store will use this file to provide a reduced-size APK for your app. This format will make the base APK of your app available to every user, and the configuration will be sent to help the APK fit in a variety of device-level requirements.
3. Minimise the count of resources count and size
The APK size of an app can significantly impact the loading speed of an app and both memory as well as power consumption. To reduce your APK size to ensure faster app download reducing the number of resources and their size can be a very effective means. You need to do away with all the unused resources and keep the sizes at a minimum. For instance, you should use scalable graphics objects instead of the image files within your app.
The Android Studio in this respect offers some helpful tools. There is a lint tool in Android Studio that works like the static code analyzer, and it promptly finds out the code resources remaining unused in the res/ folder. As soon as a potentially unused resource is found by the lint tool, it gives a message. Remember, it doesn’t remove resources but only notifies you about any unused ones.
4. Choose the libraries wisely
The Mobile app development company depends on using the external libraries for delivering a better app in respect of both usability and versatility. For instance, developers can use Google Play Services to utilize automatic text translations for users. Now, f the library is big enough to consist of several objects and methods relating to desktop users your app may not need them at all. These objects and methods will make your app unnecessarily heavier. This is why while incorporating libraries sometimes it is essential to edit the files of the library and use only the parts you need.
Alternatively, you can always opt for lean and mobile-optimized libraries bereft of all the objects and methods for desktop users. Either you need to edit the existing libraries to use the required part of it, or you have to opt for the mobile-friendly lean ones.
5. Provide on-demand features through dynamic feature modules
Many apps use a lot of features that are not definitive to the core functions and usability of an app. These features add to the bulk of the app size. You can reduce the app size by making them optional through dynamic feature modules. This allows users to access these features by downloading when they require them. This helps you keep the APK size smaller without compromising on the feature options.
For creating a dynamic feature module you need to follow the path in the Android Studio toolbar like this: select File > New > New Module. Now select the Dynamic Feature Module and click Next. Now choose your base module with core functions and give it a name. Don’t forget to select the checkbox entitled for the on-demand module.
Let us be clear that there several other ways to reduce the package size of an app and you need to give attention to each one of them. Here we just explained only a few smart ways to minimize the APK size while maintaining optimum output in all regards.
Latest posts by junedghanchi (see all)
- 5 Smarter Ways to Reduce the Android Application Package Size - April 4, 2019