'Flutter app wont run on macOS android emulator

I have an application which is working fine, in fact it's already been published on Google Play with no issue, the issue I'm facing is that this app does not run on MacOS simulator which same code without any changes or flutter clean etc. will run on WindowsOS simulator!

Therefor each time I want to upgrade or test my app I have to switch to my Windows system because it does not run on MacOs.

Here is the error that I'm getting when trying to run my app on MacOs with Android Studio/ VsCode

Launching lib/main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...


FAILURE: Build failed with an exception.

* Where:
Script '/Users/home/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1102

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/home/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 6s
Exception: Gradle task assembleDebug failed with exit code 1

What I've done so far to fix this issue:

  1. Delete my project folders such as .idea , .dart_tool , android/.gradle , build
  2. Re-run and re generate all those folders
  3. Clear/invalidate caches
  4. Flutter clean
  5. Flutter upgrade
  6. Switch between stable and master branches of flutter
  7. Completely remove and re-download flutter on my system (in new directory)
  8. Running flutter doctor and flutter doctor -v
$ flutter doctor -v
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.2.1 21D62 darwin-x64, locale
    en-ID)
    • Flutter version 2.10.3 at /Users/home/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7e9793dee1 (11 days ago), 2022-03-02 11:23:12 -0600
    • Engine revision bd539267b4
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version
    32.1.0-rc1)
    • Android SDK at /Users/home/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] VS Code (version 1.65.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.36.0

[✓] Connected device (3 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 12
      (API 32) (emulator)
    • macOS (desktop)              • macos         • darwin-x64     • macOS
      12.2.1 21D62 darwin-x64
    • Chrome (web)                 • chrome        • web-javascript • Google
      Chrome 97.0.4692.99

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Basically whatever you can find on the net I've tried, yet there is no luck with fixing this issue.

Any idea?

Update

pubspec.yaml

environment:
  sdk: ">=2.16.1 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  cupertino_icons: ^1.0.2
  flutter_launcher_icons: ^0.9.2
  font_awesome_flutter: ^9.2.0
  share: ^2.0.4
  video_player: ^2.2.19
  chewie: ^1.3.0
  youtube_player_flutter: ^8.0.0
  shared_preferences: ^2.0.13
  intl: ^0.17.0
  provider: ^6.0.2
  audioplayers: ^0.20.1
  change_app_package_name: ^1.0.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^1.0.0

flutter_icons:
  android: true
  ios: true
  remove_alpha_ios: true
  image_path: "assets/icons/logo.png"

flutter:
  uses-material-design: true

  assets:
    - assets/icons/
    - assets/db/
    - assets/videos/
    - assets/lists/

  fonts:
    - family: Roboto
      fonts:
        - asset: fonts/Roboto-Regular.ttf
          style: normal

flutter_intl:
  enabled: true


Solution 1:[1]

Enable VM acceleration on your machine. Launch Android Studio, click the AVD Manager icon, and select Create Virtual Device… In older versions of Android Studio, you should instead launch Android Studio > Tools > Android > AVD Manager and select Create Virtual Device…. (The Android submenu is only present when inside an Android project.) If you do not have a project open, you can choose Configure > AVD Manager and select Create Virtual Device… Choose a device definition and select Next. Select one or more system images for the Android versions you want to emulate, and select Next. An x86 or x86_64 image is recommended. Under Emulated Performance, select Hardware - GLES 2.0 to enable hardware acceleration. Verify the AVD configuration is correct, and select Finish.

For details on the above steps, see Managing AVDs.

In Android Virtual Device Manager, click Run in the toolbar. The emulator starts up and displays the default canvas for your selected OS version and device.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vijay Rathod