Tokopedia Nathaniel Khuana Jan 18, 2022

How We Solve the Sideloading Crash After App Bundle Implementation

Article Summary

Tokopedia shipped Android App Bundles and immediately hit a wall: mystery crashes on random devices. The culprit? Sideloaded APKs missing critical resources.

When Tokopedia adopted Google's App Bundle format in early 2019, they saved 25% on download size but discovered a critical edge case. Users installing APKs from third-party stores or shared files experienced splash screen crashes due to missing drawable resources.

Key Takeaways

Critical Insight

A few lines of code using Google's Play Core Library transformed fatal sideloading crashes into graceful reinstall prompts, protecting users who install APKs outside the Play Store.

The article includes a complete reproduction guide with sample code that shows exactly how to simulate and fix this crash before your users encounter it.

About This Article

Problem

When Tokopedia switched to Google's App Bundle format in early 2019, the app started crashing on devices that installed APKs from third-party stores or shared sources. The base-master.apk file from the splits folder was throwing Resources$NotFoundException errors on the splash screen.

Solution

Nathaniel Khuana's team added Google Play Core Library version 1.6.0 to the app and wrote some code in the Application class to detect when configuration splits were missing. When this happened, the app would show a popup letting users choose to close the app or reinstall it from Google Play Store.

Impact

The crashes that happened when users sideloaded the app became manageable instead of fatal. Tokopedia kept the 25% download size reduction from using App Bundles while protecting users who installed from outside the Play Store, and they didn't need to rewrite any code or change the source to do it.