skip to Main Content

Please I have build a simple flutter SMS reporting system but I am facing a challenge to convert my project into an APK file format. Can a flutter developer help me do that before 7th October 2024.

I have tried the CMD prompt to converting a flutter project into an APK file but I think my setup is having a gradle problem and therefore fails to convert file.

I have tried using the CMD approach:

  • flutter build apk

  • flutter build apk –release

But after I run the command I have an error message saying:

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>

2

Answers


  1. Does the project build and run successfully? It looks like you have build errors. Logs say it can not find main.dart. Make sure it’s in project_directory/lib/main.dart.

    Also you should run flutter build apk command where pubspec.yaml file lives.

    If you do everything correct and cant solve the issue, try running flutter clean and then build again.

    Login or Signup to reply.
  2. For the final release you can use the following command to generate APK or appbundle for release.

    Appbundle:

    flutter build appbundle --no-tree-shake-icons --target-platform android-arm,android-arm64,android-x64 --release
    

    APK:

    flutter build apk --no-tree-shake-icons --target-platform android-arm,android-arm64,android-x64 --release
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search