Reputation: 165
I can normally build a debug apk, but when I try to build a release or profile apk, I get the following error:
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
This is the line 896 in flutter.gradle :
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
}
I built another apps without any problems at the same laptop with the same flutter package installed.
I've read that the packages at Pubspec.yaml maybe the cause, so i did the following:
1- I tried to remove my packages at pubspec.yaml and rebuild the app, and it didnt work.
2- I added the same packages to another app and built it and it was built normally.
So, it seems that packages aren't the reason.
This is my Pubspec.yaml :
version: 1.0.0+1
environment:
sdk: ">=2.5.2 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
sqflite: ^1.1.7+1
path: ^1.6.4
path_provider: ^1.4.0
provider: ^3.1.0+1
http: ^0.12.2
connectivity: ^0.4.9+2
carousel_slider: ^2.2.1
share: ^0.6.5
# admob_flutter: ^0.3.4
url_launcher: ^5.5.3
photo_view: ^0.9.2
firebase_core: ^0.5.0
# firebase_messaging: ^6.0.12
firebase_auth: ^0.18.0+1
# cloud_firestore: ^0.14.0+2
# firebase_dynamic_links: ^0.5.0+11
# firebase_analytics: ^5.0.16
google_sign_in: ^4.5.3
# rxdart: ^0.24.1
cached_network_image: ^2.3.1
# in_app_purchase: ^0.3.4+5
# firebase_mlkit_language: ^1.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
fonts:
- family: Sons
fonts:
- asset: assets/fonts/Sons.ttf
- asset: assets/fonts/sons_of_sons.ttf
uses-material-design: true
assets:
- assets/varty.sqlite
- assets/images/photo.jpg
Upvotes: 0
Views: 1236
Reputation: 165
Evan's comment worked well and solved the problem:
This is a shot in the dark but do you use custom icons for fonts? I noticed you have two font files. If yes, try running the release apk command with --no-tree-shake-icons, I recently had an error like this with the same line number 896. Also, when you run the debug version, does the console say something like "this application cannot tree shake icons fonts. "?
Just remember to build the debug apk, then profile and finally the release one with the same command.
Upvotes: 3