Solutions for encoding (garbled) problems in Android Studio

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.