Gradle 项目 编码GBK的不可映射字符

Gradle 项目 编码GBK的不可映射字符

出现这种问题、一般是从别的项目中直接copy过来的文件、

如果是用AndroidStudio 去更改file encoding 为UTF-8

还有道友 在build.gradle  最外层添加代码、

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}


如果仍旧无效、在build.gradle添加如下代码是可行的


task androidJavadocs(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
}

task androidJavadocsJar(type: Jar) {
    classifier = 'javadoc'
    from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.srcDirs
}


artifacts {
    archives androidSourcesJar
    archives androidJavadocsJar
}


不要使用 javadocs等、也是会出现此错误


javadoc  添加这个选项是为了使它更容易从常规的makefile

Java文件生成javadocs的任务


Generates code documentation using the javadoc tool.
The source directory will be recursively scanned for Java source files to process but only those matching the inclusion rules, and not matching the exclusions rules will be passed to the javadoc tool. This allows wildcards to be used to choose between package names, reducing verbosity and management costs over time. This task, however, has no notion of "changed" files, unlike the javac task. This means all packages will be processed each time this task is run. In general, however, this task is used much less frequently.
NOTE: since javadoc calls System.exit(), javadoc cannot be run inside the same VM as Apache Ant without breaking functionality. For this reason, this task always forks the VM. This overhead is not significant since javadoc is normally a heavy application and will be called infrequently.
NOTE: the packagelist attribute allows you to specify the list of packages to document outside of the Ant file. It's a much better practice to include everything inside the build.xml file. This option was added in order to make it easier to migrate from regular makefiles, where you would use this option of javadoc. The packages listed in packagelist are not checked, so the task performs even if some packages are missing or broken. Use this option if you wish to convert from an existing makefile. Once things are running you should then switch to the regular notation.






你可能感兴趣的:(随学札记)