Deprecated imperative apply of Flutter's Gradle plugins fix 2024 | Gradle error migrate

Appblee
0


😊 Hi folks, It's Chanuka Ranathungs from Appsblee again, I hope you're here to know about how to migrate to applying gradle plugins with the declarative plugins block. Here I'm guiding you to fix this issue easily. I invite you to follow each step then you can understand the steps clearly. Also, I attached one video at the bottom of this article so you can follow the video tutorial.

First of all, let's understand the error message!

You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev./go/flutter-gradle-plugin-apply You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/go/flutter-gradle-plugin-apply

Why this error message? ❌

To build the Android version of Flutter apps, Gradle plugins must be applied. the older
But Flutter 3.16, it uses Gradle's declarative plugins {} block. (Plugin DSL) and this
one is the recommended approach in the present. After 3.16 when you create a new
Flutter project using "flutter create" command, this new Gradle's declarative plugins {}
block will be integrated into your Flutter project itself. But for the older versions of
Flutter (3.16), you must do this migration manually. Since this older gradle support will be
deprecated in the near future. So you have to do this migration asap. By adding this new
plugin method you will have some advantages rather than the previous approach.

Let's see how to migrate? 😀 Step 1:
Go to the build.gradle file located inside your Android folder you can find the current version
numbers for Gradle and Kotlin.
ext.kolin_version = '1.7.10'
classpath 'com.android.tools.build:gradle:7.3.0'
Step 2:
Now you should replace the below code block with the current code block inside the settings.gradle file in the Android folder. and replace the 1 & 2 version codes with your version codes.

Step 3:
Open the build.gradle file inside the Android folder and remove the buildscript block.
Step 4:
After that open the next build.gradle file inside android/app folder. and remove this flutter SDK code block.
Step 5:
After that place this code block at the top of the same file.
Step 6:
Now check your dependencies {} block and if this line is there.
remove it but keep the dependencies{} block.

Step 7:
After completing these steps one by one. Reload the entire project because if you do any single modification in any gradle file you should reload the project. otherwise, the changes will not be there. After reloading the project, Rerun the flutter project.

Congratulations! You have done it!🌻

If you're still struggling with the steps you can follow the tutorial in my YouTube channel. Hope you can understand the steps more clearly there :) 🎥

 Follow me on Linkedin

Tags:

Post a Comment

0Comments

Post a Comment (0)