FAILURE: Build completed with 2 failures.
I had the same issue after setting up my flutter project to run on iOS. When I tried to run it back on Android, this error was thrown.
This worked for me (on Windows):
Close your project and close your code editor
Open Task Manager
Finish all vscode-related tasks you see (or related to the IDE you are using)
Finish all Java-related tasks, inclidung OpenJDK Platform binary (there are usually two of these; finish both)
Go to your project's root folder and delete the build folder
Open your project again and run
Good luck!