Top 11 Tips on How to Improve Android App Performance

Tips to Improve Android App Performance

Performance – the most significant aspect of a mobile app. The first thing users will notice over and over again is your app’s startup time. And they are likely to give a thumbs down to the app if it’s slow. As per Nimbledroid, poor app performance has made 86% of users (counting myself in) uninstall their apps.

So, if your app needs to show some content to a user, it has less than 11 seconds to load. But here’s the sob story – only 40 out of 100 Android apps start under 2 seconds while 70 take at least 3 seconds. This answers your question of which part of the app development process you should focus the most on: it’s Android app performance.

Yes, android devices have multiple cores, so building smooth android apps is really difficult – right? Actually, it’s not. You can do a lot of things on Android in different ways, and the only challenge you’ll face is picking the best option. If you want to optimize android app performance, you must know what’s happening under the hood. Fortunately, you can find bottlenecks, show and measure what’s happening with the help of a lot of tools.

Well then, it’s time to stop relying on your gut feeling or hoping for the best and know how to improve the performance of your android app that will win the hearts of users.

Here’s the list of checkpoints we’ll walk through today:

Tips and Tricks to Improve Android App Performance

The smoother your app performs, the harder it will hit the market. Personally, I would not mind spending a couple of extra bucks for exceptionally improved performance, and I’ve seen clients do so too. Truly the wise said – time is money!

Anyway, please keep in mind that premature optimization during the mobile app development process can spoil the whole game for you. Spending time on micro-optimization won’t work for you as well. Try to optimize code that runs frequently. The onDraw() function is such an example that runs every frame with an ideal 60 times/second pace. As drawing goes slower than any other operation, redraw only when you absolutely need to.

Okay, enough theory! Let me cut to the chase and look at some actions you should consider if android app performance matters to you:

1. Reduce the App Size

Smartphones aren’t powerful GPUs yet. And here’s a jaw-dropping fact – it’s modestly configured mobile phones that consume most of the global Android market share. Even though some of them don’t support 2G/3G, users generally avoid downloading huge apps, especially when there’s a hurry. So, the less space it consumes on your phone, the better it is for users.

Let me show you some productive ways to minimize your Android app size:

Android App Bundles

Android App Bundle is the latest upload format that consists of all the resources and compiled code. It delays APK building and signing to Play Store. Such features make the job exceptionally easy as app bundles create APKs that are optimized as per the device.

Though the compressed download size of your app should be 150mb or less to publish in the Play Store, minimizing the app size as small as possible is still a great idea to improve your android app performance.

Planning to build a high-performing mobile app for your business?

Android Size Analyzer

This is an efficient Android app performance tool that can help you choose and implement a lot of solutions to shrink the size of your app. You can find Android size analyzer as an Android Studio plugin and a standalone JAR (as a command line).

As a Plugin > Install the Android Size Analyzer from the plugin marketplace in Android Studio and use it as a plugin. Run an analysis on your Android app with it, and you will find a tool window with all the suggestions on how to enhance your app performance.

As a Command-Line > Github has the latest version of Android Size Analyzer as a ZIP or TAR file. Extract the ZIP file and run the size-analyzer script so that you can see the size of your files. Additionally, the size analyzer.bat script (windows) is there to run these two commands:

./analyzer check-bundle
./analyzer check project

2. Optimize Networking

Optimize App Networking

Here’s a rule of thumb – always prioritize text before image. To optimize Android apps, you need to load the textual data first as image-based content should be your second choice, asynchronously.

Handle network requests effectively as your app will use the internet to upload or download data. One of these network requests is cellular data, and another is the battery. Heavy usage of both mobile network and WiFi consumes a lot of battery.

Suppose you have to download a 1 MB file. So you need to stimulate the mobile or WiFi radio to make a network request and download the file. However, the radio won’t sleep instantly after the task. For the next 20-40 seconds, it will be in an adequately active state based on your device.

So, can you do something about it? Yes, batching. Prefetch things that users may use and download the data they may need in the next 3-4 minutes so that the radio doesn’t wake up every couple of seconds.

You can also improve app performance by editing the batch parameters based on the user’s charging condition or internet type. For example, you can’t prefetch much data if the user is on cellular internet with a low battery, unless it’s WiFi while charging.

Efficient API Design > Android app performance heavily relies on API design. Workarounds on APIs generally bring too much pressure on network restrictions. Hence, ensure to have completeness and consistency while designing the API payloads of your android app.

Start with UI and go all the way to data to design a complete and consistent API payload that will improve android app performance.

3. Optimize Images and Videos

Optimize App Images and Videos

Apart from APIs, your Android app loads quite a number of images and videos. Usually, other properties load those images as well, like the website of your app. Images and videos on desktop websites are different (in terms of resolution, screen size, and device type) than on mobile apps.

Hence, you must optimize images and videos in your app for mobile devices with measured and limited resources. When your Android app requests images, ensure they are served with the best size and resolution. You can also use adaptive video buffering and progressive images so that your app can successively download images rather than waiting for the complete image to download. This way, users don’t view a blank image due to an improvement in perceived latency.

In the same way, adaptive video streaming techniques effectively modify the video resolution as per the network setup. When bandwidth is low, you can lower the video quality so that users can at least watch the video and not a loading screen.

Additionally, did you know that you can use the WebP format besides JPEG or PNG images as well? Yes, WebP is technically more streamlined, although you need to put extra effort into creating WebP images. And for local network traffic, SVG (Scalable Vector Graphics) format is another good choice that can save your disk space as well.

Lastly, you can use image caching, vector images, libraries like Fresco or Picasso and apply color filters instead of varied sets of colored images. All these are effective ways to improve android app performance.

4. Optimize Screen Size

Optimize App Screen Size

Screen sizes have created a lot of buzz among developers as they face considerable challenges with it. There are so many Android devices with various shapes and sizes. Rigid dimensions in your layout will only respond to a specific orientation and screen size, and thus, your app should support maximum screens as possible. Ensure your layout assumes different screens and aspect ratios so that a wider pool of audiences can access your app from different devices.

But fret not, implement these techniques to avoid any hurdle while optimizing the screen size and resolution of your Android app:

  • Use view dimensions so that you can resize the layout
  • Implement bitmaps to scale with the views
  • Build a flexible and adaptive UI
  • Develop alternative layouts
  • Provide small width qualifiers
  • Modularize fragments with UI components
  • Optimize for HDPI and MDPI

Of course, you may not have a hundred devices to check the screen size. Android emulators can help you with this.

5. Optimize Offline Model

Optimize App Offline Model

If you have bad network connectivity, try to display whatever data is possible while fetching the required data. I would highly recommend you display information in offline mode, considering performance and usability. Let me tell you what problems you could face if you don’t use caching – a horrible user experience, as it takes a long time to retrieve data due to poor network.

Now here’s what you can do about it to enhance the overall android app performance and provide a smoother user experience.

Data Synchronization

You can build a much more engaging and useful app by synchronizing data between your Android app and a web server. For instance, you can send data to a web server that will serve as a helpful backup. You can also transfer data from a server so that it’s easily available to your users, even if the device is not active.

Sensitive Data Management

Be careful with defining access to sensitive data. You can customize and set privacy parameters on your app, so that it maintains safe access to sensitive data. You can either give permissions for restricted data (including bank statements, contact information, system state, etc.) or restricted action (including taking screenshots, connecting to a Bluetooth device, recording audio, etc.)

Manage Shared Data

If your app repeatedly asks your users for a complicated password, it will bring down the overall android app performance in terms of usability. Establish control over your data as an authentication token and share it with other modules of your app.

6. Improve Memory Usage

Improve app Memory Usage

For multitasking purposes, Android has provided RAM to users. Your app will have limited RAM availability, though it can change based on the usage of your app. Such Android restrictions, along with other active apps in the background, consume redundant resources.

But you still can optimize android app performance and memory usage by:

Avoiding Memory Leaks

Memory or activity leaks are one of the critical problems you need to take care of. How do they happen? If you keep the reference to an unused activity in the code, you would actually keep all the activity’s layout, including its views. This creates a handful of pixels that you would not want to keep in memory.

Here’s what you can do about memory leaks:

  • Steer clear of static references
  • Unregister your listeners and events
  • Try to use the event bus and recoup your listeners from senders
  • Choose static inner classes over non-static ones
  • Perform code quality and standard reviews and implementations. As per my personal experience, reviewing your codes is by far the most effective way to avoid activity leaks
  • Write memory-efficient codes
  • Have a thorough knowledge of your architecture before you start writing any codes
  • Print logs on callback
  • Utilize useful tools like LeakCanary, MAT, Eclipse Analyzer
  • Minimize the use of external libraries

Improve your Android app performance for
stunning user experience

7. Scale Down the App Launch Time

Scale Down the App Launch Time

Users always want a fast and responsive app. If your app takes too long to launch, they will likely get an unpleasant experience and write negative reviews on the Play Store.

As per Google, 70% of mobile app users renounce an app if it takes a long time to load. Moreover, the top 25 apps on the Play Store take around 800 ms to 4.5s to launch. But in most cases. 4.5s is too much for users.

In short, the goal is to make your Android app run swiftly. And the factors you should look at to speed up your app launch time are:

  • Installation of many views
  • Obstructions in the initialization process
  • Running layouts
  • Expensive content

And these mitigation ways that can help you optimize Android app and speed up the launch time:

  • Use lazy initialization to postpone the building of feasibly expensive objects until you require them. For example, develop a database connection strictly when you need to gather data from the database.
  • Try to avoid using unnecessary UI elements for the first launch. If the hierarchies of your app are extendable, use placeholders that you can extend later as well.
  • While managing memory for garbage collection and powerful memory allocation, keep away from having an issue. Your process may try to get the resource but could not get any memory for allocation, leading to deadlock.
  • To provide top-notch usability, make sure your android app is well synchronized with real-time data and the latest information for users.
  • Avoid using reflection as it’s fragile, slow, and less secure. As you perform run-time checking instead of combine-time, it will also have testing issues.
  • Monitor and improve your app launch time with tools like Apteligent.
  • Keep in mind that your app will behave differently on a warm and cold start.

8. Hit a Smooth Frame Rate

Use a Smooth App Frame Rate

60fps (frames per second) is the highest frame rate for rendering gestures and animations on both Android and iOS. If your app goes slower than that, it will provide a lethargic android app performance, ruining the user experience.

Therefore, execute everything in your app’s rendering code within 16ms if you want to hit the 60fps target. You would be surprised to see how much impact a 5ms garbage collection time has on your app.

Wondering why this 16ms timeframe is so important? Let me tell you more about it. You might think a moderately lower frame rate like 58-59fps will work, but the bad news is that if your app passes over the 16ms limit and has to wait for the upcoming one. Although it only took 19ms for rendering, it missed the window, and the users now have to wait twice as long.

This will essentially leave a very bad impression of your Android app on the users. Can you have a way out of it? Yes, with Android Performance Tuner. It can help you measure and optimize graphical consistency and frame stability so that you can improve android app performance and offer a great experience to each user. Here are some benefits you can get from Android Performance Tuner:

  • Identify performance concerns and improve accuracy
  • Arrange and prioritize issues with impact metrics
  • Enhance the standard of user experience
  • Get the most suitable option for every device

Moreover, you can incorporate various modes into your app and let users select between optimal performance mode and battery saving mode.

9. Work Efficiently with Threads

Work Efficiently with App Threads

Based on my professional experience, one of the secrets to optimizing an Android app is the way you work with its threads. If your developers know how to work with thread efficiently, they can easily build a stable and high-performing app with most performance issues resolved.

But before all that, you should know that there are two key types of threads in an Android app – the primary thread (or UI thread) and the secondary (or background) thread. If you make any changes to the UI thread, it will obstruct the main thread. And until the ongoing task is done, you can’t assign it to another call or method, following the FIFO technique.

Bottom line, you should not do the following things on a UI thread:

  • Make API calls
  • Access a remote or local server
  • Load streams or images
  • Make database calls
  • Parse a JSON

10. Identify Latency Killers

Latency issues could be a serious concern for your app. Latency can cause critical app errors and sometimes crash the whole app. As we already know, 25% of mobile app users abandon their app after one use.

So to successfully deal with latency issues, I have ground out some tips:

  • When you have poor network connectivity, try to limit third-party latency sources
  • Cut down the requirement for latency killer APIs you may use on your smartphone

11. Use StringBuilder instead of String

Let’s suppose you have a String, and you want to append 5 thousand more Strings to it, for whatever reason. The code would look somewhat like this:

String string = "hi";
for (int i = 0; i < 5000; i++)
{
    string += " everyone";
}

String concatenation involves multiple trash collection operations, and thus, this code may be inefficient. You need around 5 secs to run it on a decent device. But why is string concatenation so slow? Because strings are unchangeable, and you can’t modify them. So, if you’re planning to change the value of a String, you’re only going to build a new String with the desired value.

But here comes the major drawback – until garbage collection, the value of the old String remains alive without a reference.

There’s a more constructive approach to reduce the expenses of memory and improve Android app performance.

StringBuilder sb = new StringBuilder("hi");
for (int i = 0; i < 5000; i++)
{
    sb.append(" everyone");
}
String string = sb.toString();

This code will take around 3ms to execute. If you use Android Studio Monitor for CPU and memory visualizations, you’ll see it’s practically flat. However, you can achieve such a visualization by appending 5 thousand Strings which you are usually not likely to do. So, here’s something you could do:

String string = “hi” + “everyone”;

This code will work just fine after getting converted to a StringBuilder internally.

Looking to optimize your existing Android app?

Conclusion

Here you go, all the checkpoints for improving your app performance have been summarized. But here’s the hard truth – optimizing Android apps is way more complicated than it sounds. There are a lot of ways you can implement these ten essential techniques, so you should be aware of their pros and cons.

Sadly, there’s no silver bullet that comes only with benefits, so try to understand what’s happening in the back office and pick the most effective solution for your Android app. And if you’re still not sure, you can consult the leading android app development company – Radixweb.

By following the best industry practices, our expert developers seamlessly optimize Android app performance so that your app can set a benchmark in the market.

Seems like a good idea to engage your users and level up your business? Let’s connect!

Don't Forget to share this post!

Vinit kariatukaran is a senior mobile application development manager at Radixweb and passionate about developing and designing innovative high-reach mobile applications. He endeavors to keep himself abreast of all the latest technological changes and updates to deliver the best in the business. When at leisure, he loves to read books and have interesting conversations with his colleagues and friends.