我通常可以构建调试apk,但是当我尝试构建发行版或配置文件apk时,出现以下错误:
if (TempData["DidHeJustSignUp"] != null)
{
<div class="alert alert-success text-center">
You have been registred Successfully, please Sign In
</div>
}
这是flutter.gradle中的第896行:
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 896
* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\src\flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 1s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 62.3s
Gradle task assembleRelease failed with exit code 1
我在安装了相同Flutter包的同一台笔记本电脑上构建了没有任何问题的其他应用程序。
我已阅读 Pubspec.yaml 上的软件包可能是原因,所以我做了以下事情:
1-我试图在pubspec.yaml上删除我的软件包并重建应用程序,但是它没有用。
2-我将相同的软件包添加到另一个应用程序中,并进行了构建,并且构建正常。
所以,看来这不是原因。
这是我的Pubspec.yaml:
project.exec {
logging.captureStandardError LogLevel.ERROR
executable flutterExecutable.absolutePath
workingDir sourceDir
if (localEngine != null) {
args "--local-engine", localEngine
args "--local-engine-src-path", localEngineSrcPath
}
if (verbose) {
args "--verbose"
} else {
args "--quiet"
}
args "assemble"
args "--depfile", "${intermediateDir}/flutter_build.d"
args "--output", "${intermediateDir}"
if (performanceMeasurementFile != null) {
args "--performance-measurement-file=${performanceMeasurementFile}"
}
if (!fastStart || buildMode != "debug") {
args "-dTargetFile=${targetPath}"
} else {
args "-dTargetFile=${Paths.get(flutterRoot.absolutePath, "examples", "splash", "lib", "main.dart")}"
}
args "-dTargetPlatform=android"
args "-dBuildMode=${buildMode}"
if (trackWidgetCreation != null) {
args "-dTrackWidgetCreation=${trackWidgetCreation}"
}
if (splitDebugInfo != null) {
args "-dSplitDebugInfo=${splitDebugInfo}"
}
if (treeShakeIcons == true) {
args "-dTreeShakeIcons=true"
}
if (dartObfuscation == true) {
args "-dDartObfuscation=true"
}
if (dartDefines != null) {
args "--DartDefines=${dartDefines}"
}
if (bundleSkSLPath != null) {
args "-iBundleSkSLPath=${bundleSkSLPath}"
}
if (extraGenSnapshotOptions != null) {
args "--ExtraGenSnapshotOptions=${extraGenSnapshotOptions}"
}
if (extraFrontEndOptions != null) {
args "--ExtraFrontEndOptions=${extraFrontEndOptions}"
}
args ruleNames
}
答案 0 :(得分:1)
Evan的评论很好地解决了问题:
这是在黑暗中拍摄的照片,但是您是否使用自定义图标作为字体?一世 注意您有两个字体文件。如果是,请尝试运行发行版apk 使用--no-tree-shake-icons命令,我最近遇到了这样的错误 与相同的行号896。此外,当您运行调试版本时, 控制台是否说类似“此应用程序无法树状显示” 摇动图标字体。 “?
仅记得先构建调试apk,然后使用相同的命令对配置文件进行分析,最后对发行版进行配置。