问题:Android Studio 运行Java,控制台输出汉字乱码
措施:在该Java工程目录下的build.gradle添加如下代码,然后重新运行
代码
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
添加位置
apply plugin: 'java-library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
网友评论