'Failed to apply plugin [class 'FlutterPlugin'] after updating android studio

I had just updated Android Studio and the new version details: enter image description here

I get an error when I build my project

When I build or sync my project I get the same error, before the Failed to apply plugin [class 'FlutterPlugin'] error, I got another error that I need to mention flutter.sdk in local.properties and I mentioned it, then I get the error. But there are 2 errors and not one, I think they both are together so if one is fixed the other will be fixed too.

You can see the errors below:

Error 1

Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [class 'FlutterPlugin']

Error 2

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method register() for arguments [generateLockfiles, FlutterPlugin$_apply_closure1@545cc796] on task set of type org.gradle.api.internal.tasks.DefaultTaskContainer.

Local.properties (I hope it helps)

## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Wed Feb 16 16:11:58 GST 2022
sdk.dir=C\:\\Users\\osedk\\AppData\\Local\\Android\\Sdk
flutter.sdk=C\:\\Users\\osedk\\Documents\\flutter\\flutter

Thank you for your help



Sources

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

Source: Stack Overflow

Solution Source