自動刪除未對齊的 apk
如果你不需要使用 unaligned
字尾(你可能沒有)自動生成的 apk 檔案,你可以將以下程式碼新增到 build.gradle
檔案中:
// delete unaligned files
android.applicationVariants.all { variant ->
variant.assemble.doLast {
variant.outputs.each { output ->
println "aligned " + output.outputFile
println "unaligned " + output.packageApplication.outputFile
File unaligned = output.packageApplication.outputFile;
File aligned = output.outputFile
if (!unaligned.getName().equalsIgnoreCase(aligned.getName())) {
println "deleting " + unaligned.getName()
unaligned.delete()
}
}
}
}
從這裡開始