In Android Studio, suppose our code has Chinese gaze. Display time completely normal, and compile when Gradle will error, but can compile successfully, and Gradle report error information, is garbled!
So we can not find the wrong reason, (quite deceptive ....) )
Said so much. Here's how to fix it:
In fact, the garbled error message is " encoded UTF-8 non-mapped characters ". So we can solve it in the following ways, for example
Set up the character set in the settings first:
Settings->file Encodings->ide Encodeing->utf-8
Settings->file Encodings->project Encodeing->utf-8
Assuming this is not possible, continue to look down, assuming that the following steps can be ignored
The following configuration is added to the Build.gradle under the corresponding module:
Tasks.withtype (Compile) {
options.encoding = "UTF-8"
}
But this configuration in gradle2.0 once was able to take effect, after gradle2.0 will not be effective, because Compile has been renamed to JavaCompile So the configuration that needs to be joined after gradle2.0 such as the following:
Tasks.withtype (javacompile) {
options.encoding = "UTF-8"
}
Android Studio compile gradle hint encoding error