我需要帮助将我的 flutter 项目转换为 apk 文件

问题描述 投票:0回答:1

我已经构建了一个简单的颤振短信报告系统,但我面临着将我的项目转换为 APK 文件格式的挑战。 Flutter 开发人员可以在 2024 年 10 月 7 日之前帮我做到这一点吗?

我已尝试使用 CMD 提示将 flutter 项目转换为 APK 文件,但我认为我的设置存在 gradle 问题,因此无法转换文件。

我尝试过使用CMD方法:

  • flutter 构建 apk

  • flutter 构建 apk --release

但是在运行命令后,我收到一条错误消息:

Microsoft Windows \[Version 10.0.22631.4249\]

(c) Microsoft Corporation. All rights reserved.

F:\\CurrentSMSAPP\\electionresults_results_sms_collation_mobileapp\>flutter build apk

 Building with sound null safety 

/main.dart: Error: Error when reading '/main.dart': The system cannot find the file specified.

package:electionresults_results_sms_collation_mobileapp//main.dart: Error: No 'main' method found.

Try adding a method named 'main' to your program.

Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

\* Where:

Script 'D:\\installed\\flutter\\packages\\flutter_tools\\gradle\\flutter.gradle' line: 1151

\* What went wrong:

Execution failed for task ':app:compileFlutterBuildRelease'.

\\> Process 'command 'D:\\installed\\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 36s

Running Gradle task 'assembleRelease'...                           38.5s

Gradle task assembleRelease failed with exit code 1

F:\\CurrentSMSAPP\\electionresults_results_sms_collation_mobileapp\>
flutter flutter-apk
1个回答
0
投票

项目是否构建并运行成功?您似乎有构建错误。日志说找不到 main.dart。确保它位于project_directory/lib/main.dart中。

您还应该在 pubspec.yaml 文件所在的位置运行

flutter build apk
命令。

如果您所做的一切正确但无法解决问题,请尝试运行

flutter clean
,然后再次构建。

© www.soinside.com 2019 - 2024. All rights reserved.