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 "}