Emoji symbol

给你一囗甜甜゛ 提交于 2019-11-30 17:07:58
Menny

The fix for that is: Add "--utf16" to aapt by adding

android {
    aaptOptions {
        additionalParameters '--utf16'
    }
}

to your build.gradle file, and make sure you are not using aapt2.

See https://issuetracker.google.com/issues/37140916

It seems that newer versions of Android don't cause the crash (API 24 worked in my tests), but that doesn't help if you are supporting older versions. The best I have been able to figure out is to use Java coded strings.

public class AppEmojiStrings {

    // This is only a workaround for emoji causing crashes in XML strings.
    // Use the standard strings.xml for all other strings.

    public static final String thumbsUp = "Thumbs up 👍"; 
    public static final String iLoveNY = "I \uD83D\uDC99 NY";
}

There are a number of disadvantages with this method, the main one being that it can't be accessed in the layout XML files. But it may be a viable workaround for some situations.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!