How Grammarly Built a Native Keyboard for Android
Article Summary
Grammarly's Android keyboard gets used 70+ times per day by the average user. Building it meant solving problems most app developers never face.
Grammarly's engineering team shares how they built their Android keyboard as an InputMethodService rather than a traditional app. This deep dive covers the unique architectural challenges of processing suggestions in milliseconds while maintaining a responsive typing experience.
Key Takeaways
- Multiple pipelines run concurrently at each keypress in under 20 milliseconds
- State machine orchestrates constantly changing UI views in limited screen space
- Text cache prevents expensive IPC calls while maintaining coherence across threads
- UI Automator enables testing since standard frameworks can't test IME services
- Cold starts require initializing on-device ML models without blocking user input
Critical Insight
Building a keyboard app requires managing multi-threaded pipelines, state-driven UI architecture, and aggressive performance optimization that traditional Android apps never encounter.