【发布时间】:2021-04-22 23:05:54
【问题描述】:
做flutter build apk --release --no-shrink 我成功地创建了.apk 构建并且在物理设备aswel 上运行良好。
我正在尝试使用以下命令进行混淆,这是 Flutter 文档中推荐的方式,here。
flutter build apk --obfuscate --split-debug-info=/<project-name>/<directory>
失败并抛出以下内容
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Programs\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904
* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\Programs\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 20s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 21.3s
Gradle task assembleRelease failed with exit code 1
Here 建议使用flutter build apk --obfuscate --split-debug-info=debug_info,这会使构建过程成功,但安装应用程序启动后崩溃。
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 1.22.5, on Microsoft Windows [Version 10.0.17763.1697], locale en-GB)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Android Studio (version 4.0)
[√] Connected device (1 available)
【问题讨论】:
-
我检查了所有资产,所有资产都在 pubspec.yaml 中提及