In Android Studio, whether it's your own new project, the import project, or the data returned from the network, as long as it involves Chinese, there is a high likelihood of garbled problems, resulting in the display of the phone interface does not achieve the desired effect. As shown below:
。
The solution is as follows:
(1) Open File-->settings-->editor-->file encodings, the following interface will appear:
。
In general, just set the IDE Encoding and project Encoding above. The former refers to the encoding of the IDE, which refers to the coding of your project. You can generally set it to UTF-8. But that's not the end of the list, which is just the encoding that is displayed in your Android studio, which is what you look like during programming. The second step should also be to set the compiler's encoding method.
(2) Under Project, open Gradle Scripts, and then open the Buile.gradle of your module. Add the following code to it:
Android { ... compileoptions { encoding "UTF-8" }}
This means that your project compiler will encode using UTF-8. (1) (2) after the two-step setup, the Chinese basic will not appear garbled. The final display results are as follows:
。
At this point, has solved the garbled Android studio, if there are other questions about coding, as long as the above (1) (2) to GBK, and so on, can certainly solve the problem.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Solutions for encoding (garbled) problems in Android Studio