0

I am new at flutter. I am currently using FlutterFlow to develop and for custom coding I am using Flutter on VS code.
I think I am doing something wrong while installing flutter (check flutter doctor) that's why I am getting this error.
Please let me know what is going wrong.
FYI - App runs on emulator and I am able to do USB debug but not able to make APK.

Terminal -

parthsheth@Parths-MacBook-Air fineappl-pat % flutter build apk                

 Building with sound null safety 

Target android_aot_release_android-arm failed: ProcessException: Bad CPU type in executable
  Command: /Users/parthsheth/Developer/flutter/bin/cache/artifacts/engine/android-arm-release/darwin-x64/gen_snapshot --deterministic --snapshot_kind=app-aot-elf --elf=/Users/parthsheth/Developer/New pat/fineappl-pat/.dart_tool/flutter_build/17315c88eac0b66d5360d145b85fb5b9/armeabi-v7a/app.so --strip --no-sim-use-hardfp --no-use-integer-division /Users/parthsheth/Developer/New pat/fineappl-pat/.dart_tool/flutter_build/17315c88eac0b66d5360d145b85fb5b9/app.dill
Target android_aot_release_android-arm64 failed: ProcessException: Bad CPU type in executable
  Command: /Users/parthsheth/Developer/flutter/bin/cache/artifacts/engine/android-arm64-release/darwin-x64/gen_snapshot --deterministic --snapshot_kind=app-aot-elf --elf=/Users/parthsheth/Developer/New pat/fineappl-pat/.dart_tool/flutter_build/17315c88eac0b66d5360d145b85fb5b9/arm64-v8a/app.so --strip /Users/parthsheth/Developer/New pat/fineappl-pat/.dart_tool/flutter_build/17315c88eac0b66d5360d145b85fb5b9/app.dill
Target android_aot_release_android-x64 failed: ProcessException: Bad CPU type in executable
  Command: /Users/parthsheth/Developer/flutter/bin/cache/artifacts/engine/android-x64-release/darwin-x64/gen_snapshot --deterministic --snapshot_kind=app-aot-elf --elf=/Users/parthsheth/Developer/New pat/fineappl-pat/.dart_tool/flutter_build/17315c88eac0b66d5360d145b85fb5b9/x86_64/app.so --strip /Users/parthsheth/Developer/New pat/fineappl-pat/.dart_tool/flutter_build/17315c88eac0b66d5360d145b85fb5b9/app.dill


FAILURE: Build failed with an exception.

* Where:
Script '/Users/parthsheth/Developer/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1165

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/Users/parthsheth/Developer/flutter/bin/flutter'' 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 8s
Running Gradle task 'assembleRelease'...                            9.7s
Gradle task assembleRelease failed with exit code 1

I don't know if this a system error or code error.
Let me know what other information y'all to address the problem.

Flutter Doctor -

parthsheth@Parths-MacBook-Air ~ % flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel master, 3.5.0-12.0.pre.130, on macOS 13.0 22A380
    darwin-arm64, locale en-IN)
    ✗ Downloaded executables cannot execute on host.
      See https://github.com/flutter/flutter/issues/6207 for more information

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.71.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.

2 Answers2

0

This here is the most relevant error message

[!] Flutter (Channel master, 3.5.0-12.0.pre.130, on macOS 13.0 22A380
    darwin-arm64, locale en-IN)
    ✗ Downloaded executables cannot execute on host.
      See https://github.com/flutter/flutter/issues/6207 for more information

It tells you that the flutter installation itself has not been correctly installed. And sadly, the linked GitHub issue is not very helpful as it refers to Linux systems mostly. Potential fixes for macOS are being discussed here and here. Right now you have a flutter installation which is incompatible with your system (Apple Silicon and macOS Ventura).

The solution seems to be to upgrade your flutter version

  1. flutter upgrade
  2. Remove the cache files at <flutter_installation_path>/flutter/bin/cache

After doing that, check your installation once again via flutter doctor

jraufeisen
  • 3,005
  • 7
  • 27
  • 43
  • 1
    Used 'rm -rf ~/Developer/flutter/bin/cache' This helped me to remove all error from flutter doctor. Thank you @jraufeisen – ErasableNinja Nov 13 '22 at 16:23
  • **Please refer to the answer I have posted** I have marked @jraufeisen answer as solution because he directed me to the right path, but my answer says what I have done to eliminate the issue completely. – ErasableNinja Nov 14 '22 at 05:55
0

Solved

Steps are as follow -

flutter upgrade

Upgrades flutter to latest version

rm -rf ~/Developer/flutter/bin/cache (/path/dir)

This will remove all the old cached files.

flutter doctor

This will reinstall all the cached files as per new SDK(flutter upgrade).

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, 3.6.0-2.0.pre.9, on macOS 13.0 22A380 darwin-arm64,
locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.71.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

But even after this if you try to run flutter build apk it won't work.

sudo softwareupdate --install-rosetta --agree-to-license

Accept this license and you're good to go. Turns out this was the main issue.

Thanks @jraufeisen for your help.