Just a gradle update needed
Fix broken Android Flutter build after Upgrade
You just upgraded your Flutter SDK and your Android app build doesn’t work anymore? Here’s the quick solution to fix the errors!
I have an old Flutter project created nearly 2 years ago for which I did an SDK upgrade today. Every Flutter SDK upgrade can be a challenge for such a project as there may be breaking changes. Here I want to show you how to fix an error about the Kotlin Gradle plugin.
When you build your application for Android and the error below appears, it is pretty simple to fix.
Though the Flutter Fix guidance is nice but didn’t help me at first. To fix the error, we first create a new Flutter dummy project with the command
flutter create dummy. Then we open the
android/build.gradle file of the dummy project and check the Gradle classpath.
We open the same file in our actual project and change the gradle version to match the version in the dummy project.
Afterward, we do the same with the file
android/gradle/wrapper/gradle-wrapper.properties. Here we focus on the
distributionUrl which we most likely need to change.
After these two changes, your Android build should work again. If there are still errors, it might be due to Android SDK versions. Try changing
build.gradle according to the error message. Finally, your build should work as before.
If you like the article, I would be glad to get a clap 👏 (did you know that you can clap several times? 😎) and also, if you haven’t followed me yet, I’d appreciate that as well.
By the way: In case, you don’t already have a Medium membership, I recommend using ▶ my referral link ◀ as it will give you access to all content on Medium and support me with a small portion of the fee without any extra costs for you. Thank you! ✨