Permanent fix
To fix this issue permanently, type in terminal
flutter doctor
This will give you summary like this

You need to fix all those red marks!!
Fixing android licenses
type flutter doctor --android-licenses
if you encounter this error
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
Try to install Android SDK command-line tools from Android Studio (Tools > SDK Manager)
- Unfold Appearance & Behavior
- Unfold System Settings
- Click Android SDK
- Click tab of SDK Tools
- Check Android SDK Command-line Tools (latest)
- Click Apply button

Then run once again
flutter doctor --android-licenses
Fixing Flutter plugin not installed
- Check your Android Studio Version (For Mac go to ~/Library/Application Support/Google/AndroidStudio{Version}. In my case, the {Version} is 2020.3)
- Then type
ln -s ~/Library/Application\ Support/Google/AndroidStudio2020.3/plugins ~/Library/Application\ Support/AndroidStudio2020.3
This command just redirects flutter doctor to the different folder to find plugins (where they are now). This is called symbolic link
Fixing unable to find bundled Java version
This solution is for Mac User
- Find your local Java version by typing
/usr/libexec/java_home -V
- Set Java_Home path by typing
/usr/libexec/java_home /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
- Type all of these in terminal
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
- Finally run
flutter doctor -v
to see all the details changes
Happy Ending
After fixing all those issues, run
flutter clean
flutter run
to build release apk
flutter build apk --split-per-abi