Optimizing Your Android (Go Edition) Application

Optimizing Your Android (Go Edition) Application

At last year’s Google I/O, Android (Go Edition) was announced with the goal of providing a high-quality smartphone experience for entry-level devices worldwide. Earlier this year, six OEMs announced their devices at the Mobile World Congress, and more OEMs are committed to building new Android (Go Edition) devices. We are very excited about this momentum, and we encourage you to purchase your own Android (Go Edition) device from our partners!

Our OEM partners have been working hard to bring devices to market, and we are starting to see these devices available for users. Meanwhile, I have been collaborating with the Google Play team and working with the Android developer community to ensure developers optimize their app experiences for these devices where appropriate. In this article, I will share the work of our partners optimizing their Android apps and games (Go Edition).

Understanding the Opportunity

As discussed at Google I/O, Android (Go Edition) aims to improve the experience on entry-level devices (devices with <1GB memory). Users around the world have been struggling with battery issues, lack of storage, data limits, and slow processor speeds, leading to their dissatisfaction and replacement of phones. Although Google has done a lot of work to optimize our applications, such as Search, Assistant, Maps, and YouTube, it is also important for app and game developers to ensure their products run smoothly on these devices, allowing users to enjoy a quality experience at the entry-level price point.

The requirements outlined for Android (Go Edition) are designed to help you provide an excellent experience for users on entry-level devices. As you can see, many of the optimizations for your app will actually result in smaller applications that deliver better performance for users across all devices globally.

Optimize or Start Fresh? Choose Your App Strategy

Optimizing Your Android (Go Edition) Application

Many people ask themselves the first question: “Should I optimize my existing app or create a new one?” While this question seems simple, the answer can be more complex. It also depends on factors such as how many development resources you have, whether you can retain features optimized for these devices in the app, and the types of distribution scenarios you want to enable for global end users.

There are three scenarios to consider:

  • One App for All. Use the same app for Android (Go Edition) devices and all other devices with the same experience. In this case, you are optimizing your existing app to run smoothly on these devices, and your existing users will benefit from these performance enhancements. This app may be multi-binary, but lacks specific experience for low RAM devices. We strongly recommend using the new Android App Bundle for up to 65% size savings without having to refactor your code.

  • One App, Different APKs. Use the same app for Android (Go Edition) devices and all other devices, but with different experiences. Create different APKs; one APK targeting new android.hardware.ram.low size vs APK(s) targeting all other devices.

  • Two Apps. Create a new “lite” app targeting Android (Go Edition) devices. You can keep your existing app as is. The “lite” app can still target all devices in all locales, as this “lite” app does not need to be limited to Android (Go Edition) devices.

Each approach has its pros and cons, and it is best to evaluate these options based on your specific business needs.

Tips for Optimizing Your App

Optimizing Your Android (Go Edition) Application

Once you have determined your app strategy, there are some key factors to consider while optimizing your app:

– Ensure your app has no ANR and crashes;

– Target Android Oreo;

– Your installed app should be under 40 MB, and games under 65 MB;

– The PSS of your app should be under 50 MB, and games under 150 MB;

– Keep your app or game’s cold start time under 5 seconds;

Now, let’s take a look at these performance metrics with existing Android developers as examples.

Ensure Your App Has No ANR and Crashes

Research shows that ANR (Application Not Responding) errors and crashes can have a significant negative impact on user retention and can lead to high uninstall rates. Consumers buying Android (Go Edition) phones will treat them as their first smartphones, and they will expect a pleasant, clean, and efficient experience rather than a phone that freezes. The Android vitals in the Google Play Console allow you to track ANR and crash occurrences and gain insights into errors affecting specific users or device types. This tool is essential for many of our developers to identify, categorize, and fix issues that arise in their applications.

Optimizing Your Android (Go Edition) Application

“To reduce crash rates and minimize ANR, we used important Android features and Firebase Crashlytics for proactive monitoring and managed to run with approximately 99.9% of crash-free sessions and an ANR rate of less than 0.1%, reducing our crashes by ten times compared to earlier versions,” said Arindam Mukherjee, Senior Director of User Experience and Growth at Flipkart. “To achieve this, we phased our app rollout – monitoring crashes and ANR, extensively using Nullity Annotations to catch NullPointerException issues when running static code analysis tools. We also tested versions with ProGuard enabled, which helped us catch obfuscation-related issues early in the cycle.

There are some common patterns to look for when diagnosing ANR:

– The app performs time-consuming operations involving I/O on the main thread;

– The app performs time-consuming operations on the main thread;

– The main thread is performing synchronous binding calls to another process that takes a long time to return;

– The main thread is blocked waiting for a time-consuming synchronous operation happening on another thread;

– The main thread is in a deadlock with another thread, whether within your process or through binding calls. The main thread is not waiting a long time to complete operations, but is deadlocked.

Learn more about diagnosing and reproducing crashes, and check out Flipkart’s story on optimizing for Android – Flipkart: Embracing the Indian Market with Android Go” (click to jump directly)

Target Android Oreo

Android Oreo (target API 26) includes many resource optimizations, such as background execution limits, ensuring processes run smoothly in the background while keeping the phone responsive. Many of these features are specifically designed to improve battery life and overall phone performance and ensure that users on these devices have a good experience with your app. If your app or game is not yet targeting API 26 or higher, I strongly recommend reading Google Play’s migration guide. Pay special attention to background execution limits and notification channels. Remember the announced security updates: new apps released to the Play Console must target at least API 26 (Android 8.0) or higher by August 1, 2018, while updates to existing/published apps will need to be completed by November 1, 2018. To comply with these requirements, you need to adopt Oreo as soon as possible.

Keep Installed Size Small

Optimizing Your Android (Go Edition) Application

There is a very clear correlation between APK size and install rates: the smaller the APK size, the higher the install rate. Users of Android (Go Edition) are very sensitive to disk size, as these phones typically have limited storage capacity. This is one reason why the Play Store displays app sizes exceeding app ratings in specific situations, such as in search results and Play item details. Although the Play Store on Android (Go Edition) devices is the same as the Google Play Store available to users on all devices globally, we are customizing the store experience, which we believe is very important for users on these devices.

“Our Android team focuses on users with limited network and device resources,” said AJ Cihla, Director of International Growth at Tinder. “Better yet, with the launch of Android App Bundle, we were able to reduce by 20% in a simple, sustainable way, and this naturally fits our continuous integration and deployment processes. In summary, we are looking for a 27MB APK suitable for Android Go devices; this is a significant leap from the 90MB+ bundle we released last year.

Due to the capacity limitations of these devices, it is best to keep your app under 40MB and games under 65MB. Many Google Play developers see this as a key reason why they decided to optimize their existing APK or build a separate APK targeting Android (Go Edition) devices. Here are some tips on how to keep APK size small:

  • **Use the new Android App Bundle to view size.** This year at Google I/O, we launched the Android App Bundle, a new publishing format from Google Play. With the Android App Bundle, you can build a project where the app contains compiled code, resources, and native libraries. You no longer need to build, sign, upload, and manage version codes for multiple APKs. This saves developers up to 65% in app size, and the upfront workload is relatively low. To learn more, check out Android App Bundle;

  • Replace PNG/JPG files with WebP files (if applicable). Lossy WebP compression can generate nearly identical images with smaller file sizes. For vector graphics, use SVG. For more details, see Billion Connections: Optimizing Images and WebP Overview;

  • Replace original audio formats (e.g., WAV) with MP3 or AAC for all audio resources. Any loss in audio quality should not be perceivable to most users, while still providing high-quality playback/audio listening experience with fewer resources;

  • Ensure libraries used are up to date and necessary. Consider removing duplicate libraries and updating deprecated libraries. Additionally, if available, use mobile-optimized libraries instead of server-optimized libraries. For more information, see ClassyShark;

  • Keep DEX reasonable. Dex code can take up significant space in the APK. Consider further optimizing your code to reduce APK size. Learn more about reducing code and check out our guidelines for building products for billions of users for related details.

“AliExpress understands that keeping their APK small is good business sense: remember, the smaller the APK, the more installs,” said Donghua Xun, Senior Android Engineer at AliExpress. “To keep our Android Go APK size small, we first modularized our code, then defined specific Go and regular versions using product flavors,” said Donghua Xun, Senior Android Engineer at AliExpress. “This allowed us to exclude specific feature modules (like live video) from our Go version. Then we used Gradle scripts to package this Go-edition APK along with our regular APK, all from the same codebase. We also used smaller virtual images to cover images in third-party libraries. All these actions led to an 8.8MB reduction in Android Go APK size, while the regular APK size remained at 43MB.

Keep Your Memory Footprint

Optimizing Your Android (Go Edition) Application

Android (Go Edition) phones are devices with <1GB RAM. The operating system is optimized to run efficiently in low-memory environments, and developers’ focus should be on ensuring their applications or games are optimized to use memory efficiently. When testing APKs, we look at PSS (proportional set size) to understand how much memory the application or game uses for a cold start on the device. PSS is measured as the private memory of your app plus the proportional shared memory used by your app on the device.

Follow these instructions to test memory allocation:

  • After installing the app and connecting the device to a workstation/laptop, launch the app and wait until it reaches the welcome screen (we recommend waiting 5 seconds to ensure everything has loaded);

  • In the terminal, run the command adb shell dumpsys meminfo -d (where is the pkg_id of the app being tested, e.g., com.tinder);

  • Record the value in the PssTotal column in the Total row (this value is reported in KB -> convert to MB by dividing by 1000);

  • Repeat steps 2 and 3 multiple times (at least 5 times) and average the PssTotal (KB) values.

LATAM’s largest shopping app, Mercado Libre, was able to address memory allocation and APK size requirements by focusing on the architecture of the app.

“To reduce the size of our APK, we first implemented multiple APKs through architecture and density, then separated any extra classes or resources in external libraries through ProGuard,” said Nicolas Palermo, an engineer at Mercado Libre. “From there, we confirmed whether certain libraries were necessary and removed those we didn’t need to focus on our code and resources. All our images were changed to WebP where possible, and any images not converted to WebP were compressed to the quality we required. Finally, we used the APK Analyzer to learn more about our memory usage to ensure our PSS was within acceptable limits.”

“I started aiming for SDK 26 to ensure users get the latest Android experience. From there, I looked for all static functions and static variables to see if they were really necessary, then removed those that weren’t. To pass values between Activities and Fragments, I replaced public static functions with public interfaces,” said Michel Carvajal, creator of the budgeting app Gastos Diarios 3. He added: “I also looked for loops like While and For that executed operations reading the database and tried to use AsyncTask to put most of these processes into asynchronous classes. Finally, I searched for ambiguous SQL statements to replace them with more efficient SQL statements. All these items, along with several others, helped me reduce PSS by nearly 60%.

Keep Cold Start Times Under 5 Seconds

Perception is key. In user testing and research, people feel frustrated waiting for an app or game to load for 5 seconds, leading to abandonment and uninstalls. You should treat this as your window to ensure you have a user and do not give them a chance to abandon your app after installing it on their phone. We always measure cold start times, as this is the time your app has to fully interact with the user. After completing a restart test device, it is best to run tests within the cold start time.

“When considering size requirements, we focus on image compression formats, sound clip lengths, and image resolutions,” said Amitabh Lakhera, Vice President of Production at JetSynthesys, makers of Sachin Saga Cricket Champions. “For startup time optimization, reducing data loading, setups, and background utilities helps save a lot of time. In addition, optimizing game shaders and avoiding checks like player profiles, game balancing files, and forced updates significantly speeds up game starts. Removing internet connections at startup and using anti-cheat tools can prevent players from engaging in any potential misconduct during the game and reduce memory usage.

Overall, when considering how to get your Android app ready (Go Edition), keep in mind the various optimizations and adjustments above. By using the guidance above, all developers have completed the work of optimizing their apps and games, and I believe you will be able to achieve similar results!

Optimizing Your Android (Go Edition) Application Click to end of screen | Read Original Text | You can view the official Android Go optimization guide

Optimizing Your Android (Go Edition) Application

Recommended Reading:

· Flipkart: Embracing the Indian Market with Android Go

· Material Design is Now More Than Just a Design Guide

· This Classic “Must-Have” App is Revamping with Kotlin While Deepening its Market Focus

Optimizing Your Android (Go Edition) Application

Leave a Comment

×