在build.gradle(:app)里面奄毡,想在配置完后執(zhí)行一個(gè)壓縮任務(wù):
以上代碼表示折欠,apk在編譯配置即將結(jié)束的時(shí)候,會(huì)將task zip任務(wù), 注入在gradle的執(zhí)行流程里锐秦,當(dāng)單獨(dú)運(yùn)行task zip任務(wù)的時(shí)候咪奖,因?yàn)樗赼pk編譯執(zhí)行流程里面,所以它就會(huì)啟動(dòng)apk的編譯酱床,隨后執(zhí)行task zip任務(wù)
但是 當(dāng)運(yùn)行上面的task zip任務(wù)時(shí)羊赵,報(bào)了以下錯(cuò)誤:
Execution failed for task ':app:zip'.
> Entry output-metadata.json is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.6/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
這里的意思就是gradle需要一個(gè)對(duì)重復(fù)文件的處理策略,所以給任務(wù)里面加個(gè)策略就行:
duplicatesStrategy 'exclude' ?或者是 'include'