Gradle reports garbled Characters During Android Studio Compilation

Source: Internet
Author: User

Gradle reports garbled Characters During Android Studio Compilation

In fact, this problem has been plagued for a long time, but it has no effect on compilation, and it has been put on it all the time. Today I have encountered it again. I can't see it, so I will find a solution. Then, all the answers found are the same, and they are also tried. They are useless. Nima, too much.

The problem is that the Code contains Chinese characters and Chinese characters are in comments. It is completely normal when displayed. However, gradle reports an error during compilation, but it can be compiled successfully. This Nima really hurts .. The prompt information is garbled. Don't ask me how you got the information below the Garbled text. This is not important, but how to solve it.

Gradle reported an error message "non- able characters for encoding UTF-8" during compilation"

First, set the character set in settings,

Settings-> File Encodings-> IDE Encodeing-> UTF-8
Settings-> File Encodings-> Project Encodeing-> UTF-8

If this is not the case, proceed to the next step. If this is the case, ignore the following steps.

Many answers on the Internet are to add the following configuration in build. gradle of the corresponding module.

Tasks. withType (Compile) {options. encoding = "UTF-8 "}

However, this configuration will take effect before gradle2.0 and will not take effect after gradle2.0 because

Compile has been renamed JavaCompile

The configuration to be added after gradle2.0 is as follows:

Tasks. withType (JavaCompile) {options. encoding = "UTF-8 "}

Related Article

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.