'Problem with Android Studio in running Flutter project

Can anyone tell me what's wrong with Android Studio. I cannot run flutter projects. It returns the error showed in the picture.

Android Studio version: 3.6.3 Flutter version: 1.22.1 with Dart 2.10.1

The Error showed while executing main.dart:

Launching lib\main.dart on Android SDK built for x86 in debug mode... Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

  • Where: Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 41

  • What went wrong: A problem occurred evaluating script.

FlutterPlugin

  • 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 23s Exception: Gradle task assembleDebug failed with exit code 1

Error message from main.dart



Solution 1:[1]

I have faced this error before and the solution that works for me is to clean the build folder by using

flutter clean

and uninstall the app from emulator/connect to any other device

Solution 2:[2]

I changed the virtual device's x86 image to x86_64 and the problem was solved. Still don't understand the underlying cause, but it worked.

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 Piyush Dubey
Solution 2 Adie RT