我下载了一个示例应用程序,并且出现此错误:
错误:在类型为org.gradle.api.DefaultTask的任务':app:genicebugListing'上找不到参数[build_78kboy1mhg1n1dgllveunwpn8 $ _run_closure1 $ _closure4 $ _closure9 @ 3b986d06]的方法leftShift()。
我读到解决方案是做出do last {}语句,但是我不知道如何实现它,否则它向我显示了错误。
task("generate${variant.name}Listing") {
def collection = files(variant.javaCompile.source) + fileTree(dir: 'src/main/res', include: '**/*/*.xml')
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("out.tex"), "UTF-8"
));
collection.collect { [relativePath(it), it] }.sort().each { ArrayList<Object> l ->
if (l.get(1).text.size() > 0) {
println l.get(0)
def reader = l.get(1).newReader();
writer.write("\\begin{lstlisting}[caption=${(String) l.get(0).replace("src\\main\\java\\de\\fhdw\\ergoholics\\brainphaser\\", "").replace("\\", "/").replace("_", "\\_")}]")
writer.newLine();
char[] buffer = new byte[0xFFFF];
while (true) {
def len = reader.read(buffer);
if (len == -1) break;
writer.write(buffer, 0, len);
}
writer.newLine();
writer.writeLine("\\end{lstlisting}")
writer.newLine();
}
}
writer.flush();
writer.close();
}
}