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!

Photo by Elisa Ventur on Unsplash

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.

Build errors for Android after Flutter SDK upgrade 1

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.

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/ 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 compileSdkVersion, minSdkVersion, and targetSdkVersion in build.gradle according to the error message. Finally, your build should work as before.

Flutter build.gradle

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.

🌲|☕ coffee|🎁 donate|💻 GitHub|🔔 subscribe

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! ✨

Credits go to Suragch on StackOverflow who solved the problem.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store