Android displays text in wrong encoding after update to Java 8

后端 未结 2 660
臣服心动
臣服心动 2020-12-19 04:08

I\'ve updated my project to SDK version 24 and Java 8 and encountered a strange encoding issue.

By some strange reason Android treats my hardcoded UTF-8 strings as

相关标签:
2条回答
  • 2020-12-19 04:40

    I had the same issue in Windows(but not Mac OSX). this line solve my problem(put it in gradle.properties of your project):

    org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
    

    note that this part change encoding:

    -Dfile.encoding=UTF-8
    
    0 讨论(0)
  • 2020-12-19 04:50

    This is a bug in Jack compiler, have a look at this post.

    Jack has been using the default VM encoding, which on windows is windows-1252. So, your text is encoded with UTF-8 and decoded with windows-1252 by Jack compiler, and this is why they became garbled.

    Until now, Gradle Plugin doesn't support an API to set the decode format, so we need to wait...

    0 讨论(0)
提交回复
热议问题