Android: Modern emoji support by upgrading appcompat

247 views Asked by At

I am trying to enable modern emoji support in my app for Android 10 and below. For this I have upgraded AppCompat to version 1.4.0 following this guide.

However, modern emojis still don't show up. I have gone through and verified instructions as well.

Then I tried the second approach - by directly including emoji2 dependency and using androidx.emoji2.widget.EmojiTextView instead of AppCompatEditText in my layout. This doesn't work on its own. But, it works when I explicitly disable EmojiCompatInitialize from manifest and initialize EmojiCompat in my app , i.e.:

In manifest:

         <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            android:exported="false"
            tools:node="merge">
           <meta-data android:name="androidx.emoji2.text.EmojiCompatInitializer"
                tools:node="remove"/>
        </provider>

In my activity onCreate():

        val fontRequest = FontRequest(
            "com.google.android.gms.fonts",
            "com.google.android.gms",
            "Noto Color Emoji Compat",
            R.array.com_google_android_gms_fonts_certs
        )
        val config = context?.let { FontRequestEmojiCompatConfig(it, fontRequest) }
        if (config != null) {
            EmojiCompat.init(config)
        }

But this is not the recommended way as per the docs as it requires custom initialization and using explicit EmojiTextView in layout files.

Could someone please help me understand why upgrading only AppCompat is not working for me?

0

There are 0 answers