9 Ways to Reduce Android App Size During Android App Development
Android App size is one of the most significant factors affecting your app’s install and uninstalls metrics. Here are the ways to reduce app size.
Join the DZone community and get the full member experience.
Join For FreeWith more and more digitalization, there are more requirements for mobile and mobile apps that we use daily. The increase in mobile storage spaces raised to 256 GB, which is sure to increase as we meet customer needs, add new features, and support apps on different screen sizes.
Based on the report, 74% of the world uses Android, and around 70% of users look for the app size before installing any app.
And, to our surprise, 70% of people in arising markets look for the size of an app because they are worried about data cost and phone storage space.
Since you are reading this article, there are two possibilities. Either you’re a normal user (reader) who faces this above problem - just like me or a hired Android app developer who has the power to not let users face this issue by just reducing an android app during the Android app development lifecycle.
But, this article is all about how you can optimize or reduce your Android APK size during Android app development. Therefore, if you are a beginner or experienced android app developer, these techniques and ways will surely help you develop a normal and standard android application that will not require more space.
Android App Size That Matters
In this mobile-driven world, the popularity of mobile applications has been increasing immensely daily. And because of this reason, it also increases the demand for app developers who develop Android and iOS-based applications for both platforms. But having a good experience in Android and iPhone app development, we have seen that not every Android or iOS application stands up to the mark and gets successful. In other words, we can say that not every smartphone user prefers every application.
But you know why? What are the actual reasons behind this? Well, we have figured out that as per the report by Google, if an app size is more than 150 MB, which was earlier 100 MB, the chances of its installation are going to be lowered by 30%. Also, for every 6 MB expansion in size, the install conversion rate could drop by 1%. As per the research, 65% of people would not install the app if they find out an app is too large. They will avoid such apps due to the high consumption of internet data and also storing more space.
Now, Google has come up with a better solution. It has come up with Android App Bundle, and this allows you to install apps without even downloading essential elements which are anyway present in other apps on the Play Store, thus helping in decreasing size, almost by 35%, as believed by Google.
So, now the question is, what if your android app requires more space? And you know, if your app occupies more space, then people would not prefer to download it at all. You can understand the fact that no user wants to go through trouble after spending much data on just one app.
So, now let’s have a look to reduce the android app size or APK size during Android app development.
1. Use Android App Bundle to Reduce App Size
When you have developed your android app and are ready to release your app, you have to choose between APK and Android App Bundle. The Android App Bundle will make Google play create the APK with only those specific users that require features.
Android App Bundle
- For a publishing format consisting of compiled code and resources of your app, Android App Bundle is used and delays APK generation and signing to Google Play.
- With Android App Bundles, the compressed download size restriction is 150 MB. The app bundle cannot be used with APK expansion files.
2. Use Proguard
To reduce your app APK size, Proguard is likely one of the most useful tools. It will directly reduce the source code files to a minimum and can lower the APK file size up to 90%.
- Whenever using "Proguard, try to use all variants."
- Proguard helps avoid disputes at the generated APK or bundle if used in all the variants while developing.
- ProGuard renaming or removing any fields on these data classes is not what we can do as they have to match the serialized format.
3. Use Android Size Analyzer Plugin
To considerably reduce the size of your Android App, the Android Studio plugin is your option. With the APK Analyzer, Android developers will accomplish the following:
- View the complete and comparative size of the APK.
- Know the composition of DEX files.
- Fast view of the final versions of files in the APK, such as the AndroidManifest.xml file.
- Conduct a side-by-side comparison of two APKs.
4. Image Optimization
Higher resolution images are always the best and first choice for attracting users to the website. Since the latest mobile device comes with a good camera resolution, the image size might as well be reduced by diluting the resolution. In case you don’t want to lose your image quality, then you have to convert your .jpg or .png images to .webp.
Utilizing images without reducing the size may affect the app's quality. Rather than uploading or using the original image in your app, convert your .jpg and .png images to web format. For png files, you can also use tools like pngcrush or Zopflipng. For jpg files, you can use tools like packJPG and Guetzli. You can also use vector graphics, as it makes an image simple and utilizes space.
android {
defaultConfig {
vectorDrawables.useSupportLibrary true
}
}
It is a fact that images can do wonders without static resources. At runtime, the framework is sufficient to draw such images dynamically. Besides, using the Vector Drawables objects is a great idea when small-sized apps are created.
As these apps can survive in minimal space within the APK file and create pictures compliant with material design rules, using Vector Drawables is valuable. One should also take care about the tussle that could arise concerning CPU and RAM usage as complex objects.
5. Support for Specific Screen Densities
To reduce the Android App Size, utilizing specific screen densities in the right way is another great option. There are a million Android-enabled devices with varied screen densities. Yet, we don't use entire screen densities and can eliminate what is not required.
To destroy bundling all unused screen densities into your app, analyze to determine the % of users with devices that have specific densities. If this % ratio is insignificant, you have a reason to eliminate them and lighten your app size.
6. Removing Dead Code
The size of the APK file is directly related to the load speed of your app, the memory it occupies, and the power it consumes. So, any unused or inappropriate code kept for the sake of keeping would only add to the junk. This is why the removal of dead code or code elimination is required for your app to stay active and energized all time, all day.
This code removal will enhance the quality of source code and lower the need to maintain code size, thus manifesting a healthy app overall.
7. Reuse Your Resource
Reusing is really better and simpler than removing. It’s an amazing way to utilize your resources in various manners. It gives you a smooth scrolling performance. It can help you reduce the final size of your Android APK. You can eliminate those resources that are only a rotated equivalent of another resource.
Suppose you may have tactful resources to characterize varieties in an image pertaining to tints, shades, and direction. However, you could utilize the same resources for other images.
8. Multiple APK Files Support
Some APKs consist of content that gets downloaded but is barely ever utilized. For example, add-ons like additional languages are not always needed; however, they are downloaded anyhow. This occupies the additional spaces in your storage and enlarges the app.
However, this trouble has made the developer's mind work towards better solutions to download only certain parts of an app beneficial to the users. Unfortunately, it’s not possible to download a useful part of an APK.
But to make it work nearer to these solutions, you can upload the app over the Google Play store via the Android App Bundle, which allows Google to enable optimized APKs on the basis of device configuration. For this, you can divide one app into multiple APKs. After this, users can get only those APKs that are beneficial for them as per their device configuration.
9. Avoid Enumerations
Enums are dubious. A single one can be easily added anywhere in the range from 1.0 to 1.4 KB to the classes.dex file of an application. These can consume a whole lot of high speed if there are complex frameworks or shared libraries.
So, how can you overcome this problem? Well, with the use of ProGuard, you can convert the enums into integers, and the end result is a reduced-size app.
Final Thoughts
Well, these are just simple techniques that you can implement in your Android app during the Android app development phase. This will surely help you understand how you can reduce your app size or APK file and increase efficiency.
Being an Android app developer, these methods you should keep in your mind while developing an app. By reducing the app size, you are encouraging more people to download it on their smartphones.
Published at DZone with permission of Kiran Beladiya. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments