Enhancing User Experience: Reducing ANR Rates with DataStore in Skeelo Android App
Article Summary
Skeelo's Android app was freezing on users. The culprit? SharedPreferences blocking the main thread and triggering ANR errors.
The Skeelo engineering team migrated from SharedPreferences to Jetpack DataStore to eliminate Application Not Responding (ANR) errors. They took a phased approach, prioritizing the most critical functions causing crashes using Firebase Crashlytics and Sentry data.
Key Takeaways
- SharedPreferences performs blocking I/O on main thread, causing 5+ second freezes
- DataStore uses Kotlin coroutines and Flow for non-blocking async operations
- Phased migration prioritized high-impact functions using crash analytics data
- Significant ANR reduction achieved with smoother, more responsive user experience
Migrating from SharedPreferences to DataStore dramatically reduced ANR rates and improved app stability through asynchronous, non-blocking data operations.
About This Article
SharedPreferences had concurrency issues that corrupted data when multiple threads accessed it at the same time. This caused extra latency and ANR errors whenever operations took longer than 5 seconds on the main thread.
Skeelo Engineering switched to Preferences DataStore with Kotlin coroutines and Flow. They migrated the codebase function by function, using Firebase Crashlytics and Sentry crash data to prioritize which parts to update first.
DataStore's asynchronous approach removed blocking I/O operations from the main thread. ANR rates dropped significantly, and users experienced fewer freezes and crashes. The app became noticeably more stable overall.