在以前版本的gradle中,我有如下代码,用于为我的发布版本生成outputFileName。
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(outputPathName)
}
}
但是在最后一次gradle更新后,此代码无效。我已阅读官方迁移文档,我应该将代码更改为:
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
这不起作用。此代码只在/home/pugman/AndroidStudioProjects/clickerapp/app/build/outputs/apk/release
目录中创建路径。
我也读过这段文字:
“然而,涉及访问outputFile对象的更复杂的任务不再起作用。这是因为在配置阶段不再创建特定于变体的任务。这导致插件不能预先知道它的所有输出,但它也是意味着更快的配置时间。“
这是否意味着上述方法不起作用?
答案 0 :(得分:2)
正如你所说,official migration docs表示3.0.0中引入了重大变化。话虽如此,它也清楚地说:
它仍适用于简单的任务,例如在更改期间更改APK名称 建立时间
确实它确实:)
但我怀疑你build.gradle
可能做错了什么。无论如何,请注意他们在示例中使用applicationVariants
作为前缀android
:
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
但是,前缀不需要,除非你在android
关闭之外,例如:
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
// More stuff here...
}
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "${variant.name}-${variant.versionName}.apk"
}
}
如果这不能解决问题,那么您最有可能发出的问题是build.gradle
中的其他地方。
答案 1 :(得分:0)
在你的模块build.gradle.kts
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Classificador de Vidro</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<nav class="navbar bg-primary justify-content-center">
<ul class="nav">
<li class="nav-item" >
<h2 style="color: white; width: 100%;">ML para prever tipo de vidro</h2>
<h6 style="color: white; width: 100%; margin-left: 21%;">
®Made by <a href="https://freddomingues.github.io" target="_blank" style="color: white;">
<b><u>Frederico A. Domingues</u></b>
</a>
</h6>
<h6 style="color: white; margin-left: 30%;">
<a href="https://github.com/freddomingues/curso-machine-learning/tree/master/Classifica%C3%A7%C3%A3o" target="_blank" style="color: white;">
<b><u>Ver código no GitHub</u></b>
</a>
</h6>
</li>
</ul>
</nav><br>
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<li class="page-item"><a class="page-link">Prever com:</a></li>
<li class="page-item"><a class="page-link" href="#">Naive Bayes</a></li>
<li class="page-item"><a class="page-link" href="indexRL.html">Regressão Logística</a></li>
<li class="page-item"><a class="page-link" href="indexSVM.html">SVM</a></li>
</ul>
</nav>
<div class="card" style="margin-left: 15%; margin-right: 15%; margin-top: 30px; ">
<h5 class="card-header">Classificador com Naive Bayes</h5>
<div class="card-body">
<form id="form" action="{{ url_for('predict_nb')}}" method="post">
<div class="form-group">
<label for="labelRI">RI (Índice de Refração)</label>
<input class="form-control" name="inputRI">
</div>
<div class="form-group">
<label for="labelNa">Na (Sódio)</label>
<input class="form-control" name="inputNa">
</div>
<div class="form-group">
<label for="labelMg">Mg (Magnésio)</label>
<input class="form-control" name="inputMg">
</div>
<div class="form-group">
<label for="labelAl">Al (Alumínio)</label>
<input class="form-control" name="inputAl">
</div>
<div class="form-group">
<label for="labelSi">Si (Silício)</label>
<input class="form-control" name="inputSi">
</div>
<div class="form-group">
<label for="labelK">K (Potássio)</label>
<input class="form-control" name="inputK">
</div>
<div class="form-group">
<label for="labelCa">Ca (Cálcio)</label>
<input class="form-control" name="inputCa">
</div>
<div class="form-group">
<label for="labelBa">Ba (Bário)</label>
<input class="form-control" name="inputBa">
</div>
<div class="form-group">
<label for="labelFe">Fe (Ferro)</label>
<input class="form-control" name="inputFe">
</div>
<button type="submit" class="btn btn-primary" onclick="">Verificar</button><br>
</form>
{{ prediction_text_nb }}
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>