As we use more mobile apps every day, the storage space in phones has grown to 256 GB and will likely keep increasing. Android app developers find it tough to make apps that use less space and run well on smartphones.
This article focuses on helping Android app developers, whether they're beginners or experienced, to make smaller and more efficient apps. It gives techniques to reduce the size of Android apps so they don't take up too much space on smartphones.
Why Does Android App Size Matter?
In today's world where mobile apps are really popular, there's a big demand for developers who make apps for Android and iPhone. But even if developers know a lot about making apps for these phones, not all the apps they make become popular. This means that not all phone users like or use every app that's made.
Do you want to know why some apps aren't popular? Google's report says if an app is larger than 150 MB (before it was 100 MB), there's a 30% lower chance people will install it. For every 6 MB added, the chances drop by 1%. Research shows that 65% of people won't install big apps because they use too much internet data and take up too much space on their phones.
Google made a solution called the Android App Bundle. It lets you install apps without downloading everything, which can make apps 35% smaller, according to Google. But if your app needs a lot of space, people might not want to download it. Users don't want to waste data on a big app that causes trouble.
Now, let's see how we can make Android apps smaller or reduce their size while we're developing them.
Make your app smaller by using the Android App Bundle.
When you're done making your Android app and want to launch it, you need to pick between the APK and Android App Bundle. Choosing the App Bundle means Google Play will create an APK tailored for users, including only the features they need.
Android App Bundle
The Android App Bundle is a way of packaging your app's code and resources. It shifts the APK creation and signing process to Google Play, postponing it until users download the app.
Android App Bundles have a limit of 150 MB for the size of compressed downloads. Also, APK expansion files cannot be used with app bundles.
Use Proguard
Proguard is a helpful tool to make your app's APK smaller. It shrinks the source code files significantly and can cut down the APK size by as much as 90%.
- When using "Proguard," make sure to use it with all versions or options available.
- Using Proguard with all the different versions of your app during development helps prevent issues in the final APK or bundle that is generated.
- We can't rename or remove any fields in these data classes when using ProGuard because they need to match the serialized format.
Using the Android Size Analyzer Plugin.
To significantly shrink your Android App's size, use the Android Studio plugin. This tool, called the APK Analyzer, helps Android developers achieve the following:
See the total size and compare sizes of different APKs.
Understand what's inside the DEX files.
Quickly check the last versions of files in the APK, like the AndroidManifest.xml file.
Compare two APKs directly to see the differences.
Image Optimization
Big, clear pictures are great for getting people to visit a website. If you want smaller image sizes without losing quality, change your .jpg or .png pictures to .webp format.
Using large images without making them smaller can make your app less good. Instead of using the original image, change your .jpg and .png images to a web-friendly format. For PNG files, you can use tools like pngcrush or Zopflipng. For JPG files, you can use tools like packJPG and Guetzli. You can also use vector graphics because they make images simpler and use less space.
Images can work well without being fixed resources. The system can draw these images as needed when the app runs. Using Vector Drawables is smart when making small apps. They fit well in the app's space and follow design rules. But, be careful because complex objects might use up CPU and RAM.
Provide support for certain screen qualities or resolutions.
To make your Android app smaller, using specific screen qualities properly is a good idea. Many Android devices have different screen qualities, but we don't need to include all of them in the app. To avoid adding unnecessary screen qualities, check the percentage of users with devices having specific qualities. If the percentage is very low, you can remove those qualities to reduce the app size.
Removing Dead Code
The size of your app's APK file affects how fast it loads, how much memory it uses, and how much power it needs. Keeping unnecessary or unused code only adds clutter. That's why removing unnecessary code is important to keep your app active and efficient. Removing this code makes your source code better and reduces the need to manage its size, resulting in a healthier app overall.
Reuse Your Resource
Reusing things is easier and better than getting rid of them. It's a great way to use your resources in different ways. Reusing helps make scrolling in your app smoother and can make your Android APK smaller. You can remove resources that are just duplicates of others, like rotated versions of the same image. For example, you can cleverly use resources that show variations in color, shade, and direction for multiple images.
Multiple APK Files Support
Some APKs contain stuff that's downloaded but hardly ever used, like extra languages that not everyone needs. This takes up space and makes the app bigger.
Developers are trying to solve this problem by finding ways to download only the parts of the app that users really need. Unfortunately, it's not possible to download just a useful part of an APK.
But to get closer to this idea, you can use the Android App Bundle on the Google Play store. This lets Google make optimized APKs based on each device's settings. You can split one app into multiple APKs, so users only download what's useful for their specific device.
Avoid Enumerations
Enums can take up a lot of space in your app's files. If you use ProGuard, you can change enums into integers, which makes your app smaller.
Final Thoughts
These simple techniques can help shrink your Android app size during development, making it work better. As an Android app developer, it's important to remember these methods. Smaller apps are more likely to be downloaded by people. As a leading company offering Android app development services for 10 years, we've built over 300 successful applications. Our experienced Android app developers know these tactics well and apply them to reduce app sizes effectively.