Emoji2

Display emoji in current and older devices.
Latest Update Current Stable Release Next Release Candidate Beta Release Alpha Release
June 2, 2021 - - - 1.0.0-alpha02

Declaring dependencies

To add a dependency on Emoji2, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

Groovy

dependencies {
    def emoji2_version = "1.0.0-alpha02"

    implementation "androidx.emoji2:emoji2:$emoji2_version"
    implementation "androidx.emoji2:emoji2-views:$emoji2_version"
    implementation "androidx.emoji2:emoji2-views-helper:$emoji2_version"
}

Kotlin

dependencies {
    val emoji2_version = "1.0.0-alpha02"

    implementation("androidx.emoji2:emoji2:$emoji2_version")
    implementation("androidx.emoji2:emoji2-views:$emoji2_version")
    implementation("androidx.emoji2:emoji2-views-helper:$emoji2_version")
}

For more information about dependencies, see Add Build Dependencies.

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

1.0.0

Version 1.0.0-alpha02

June 2, 2021

androidx.emoji2:emoji2:1.0.0-alpha02, androidx.emoji2:emoji2-views:1.0.0-alpha02, and androidx.emoji2:emoji2-views-helper:1.0.0-alpha02 are released. Version 1.0.0-alpha02 contains these commits.

API Changes

  • Renamed package in emoji2-views-helper to androidx.emoji2.viewsintegration. This is a breaking change for AppCompat 1.4.0-alpha01, and apps must ensure AppCompat dependency is updated to use the new emoji2 version. (Ie8397)

Version 1.0.0-alpha01

May 18, 2021

androidx.emoji2:emoji2:1.0.0-alpha01, androidx.emoji2:emoji2-views:1.0.0-alpha01, and androidx.emoji2:emoji2-views-helper:1.0.0-alpha01 are released. Version 1.0.0-alpha01 contains these commits.

Features in this initial release

Integrating emojicompat is recommended for all apps to support modern emoji from API19. All user generated content in your app contains 🎉.

EmojiCompat has moved from the androidx.emoji artifacts to the new androidx.emoji2, now in alpha01. The new artifacts replace the previous version.

emoji2 is added as a dependency to AppCompat starting in AppCompat 1.4.0-alpha01 and is enabled by default for AppCompat views.

The emoji2 artifact introduces a new automatic configuration using the androidx.startup library. You no longer need to write any 👨🏽‍💻 code to display 🐻‍❄️.

Changes in emoji2 from emoji

  • Added new automatic configuration EmojiCompatInitializer using androidx.startup.
  • Added new default configuration that uses service location to find a downloadable fonts provider in DefaultEmojiCompatConfiguration.
  • Classes moved from androidx.emoji package to androidx.emoji2.
  • Split EmojiTextView and related views to a separate artifact emoji2-views. This should only be used if your app doesn't use appcompat.
  • Extracted helpers for integrating emojicompat into custom views into a separate artifact emoji2-views-helper.
  • Added nullability annotations.
  • Helpers in emoji2-views-helper may now be used even when EmojiCompat is not initialized (previously they threw an exception).

What dependency should you add?

  • Apps with AppCompat should upgrade to appcompat version AppCompat 1.4.0-alpha01 or higher.
  • Apps without AppCompat using TextView/EditText from platform should use EmojiTextView and related classes from emoji2-views.

How to support in custom views

  • Apps with AppCompat should extend AppCompatTextView, AppCompatButton, etc. instead of platform TextView, etc.
  • Apps without AppCompat should add androidx.emoji2:emoji2-views-helper dependency and use helpers to integrate with custom TextView or EditText subclasses.

Configuring automatic initialization

  • Apps can disable the automatic initialization by adding this to the 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>
    
  • This disables automatic configuration, and you can then pass a custom configuration to EmojiCompat.init. The default configuration for the system may be retrieved DefaultEmojiCompatConfig.create(context) for further configuration before passing to EmojiCompat.init.