With the EmojiCompat library(part of the Support Library 26) your app can get backward-compatible emoji support on devices with API level 19+ and get rid of ☐ (tofu).

How does EmojiCompat work?

For a given char sequence, EmojiCompat can identify the emojis, replace them with the EmojiSpan, and then render the glyphs.On versions prior to API level 19, you’ll still get the tofu characters. EmojiCompat build on the new font mechanism to make sure you always have the latest emoji available.

Downloadable fonts configuration of emoji

The downloadable fonts configuration uses the Downloadable Fonts support library feature to download an emoji font. It also updates the necessary emoji metadata that the EmojiCompat support library needs to keep up with the latest versions of the Unicode specification.

Adding support library dependency

Support Library 26 has now been moved to Google’s maven repository, first include that in your project level build.gradle.

buildscript {
   repositories {

Add the support library in your app level build.gradle.

dependencies {
    compile "com.android.support:support-emoji:26.0.2"

Adding certificates

When a font provider is not preinstalled or if you are using the support library, you must declare the certificates the font provider is signed with. The system uses the certificates to verify the font provider’s identity. Create a string array with the certificate details.

<?xml version="1.0" encoding="utf-8"?>
    <string-array name="certs">

Initializing the downloadable font configuration

Before using EmojiCompat, the library needs a one-time asynchronous setup(in application class).

FontRequest fontRequest = new FontRequest(
                "Noto Color Emoji Compat",

When a downloadable font configuration, create your FontRequest, and the FontRequestEmojiCompatConfig object.

config = new FontRequestEmojiCompatConfig(getApplicationContext(), fontRequest)
                .registerInitCallback(new EmojiCompat.InitCallback() {
                    public void onInitialized() {
                        Log.i(TAG, "Emojicompact Initialize");
                    public void onFailed(@Nullable Throwable throwable) {
                        Log.e(TAG, "Emojicompact Initialize failed " + throwable);

It depends on the way you’re using it, the initialization takes at least 150 ms, even up to a few seconds. So you might want to get notified about its state.for this, use the registerInitCallback method. Use EmojiCompat widgets in layout XMLs. If you are using AppCompat, refer to the Using EmojiCompat widgets with AppCompat section.


You can preprocess a char Sequence using the process method. You can then reuse the result instead of the initial registering in any widget that can render spanned instances.So, for example, if you’re doing your own custom drawing, you can use this to display emoji text.

EmojiCompat.get().registerInitCallback(new EmojiCompat.InitCallback() {
       public void onInitialized() {
            final EmojiCompat compat = EmojiCompat.get();
                  compat.process("Normal TextView \uD83D\uDE48\uD83D\uDE49\uD83D\uDE4A"));

Download this project from GitHub]]>