Demystifying the SDK Version Error in Flutter App Development
Read Time 4 mins | Written by: Kenneth Hough

Hey there Flutter enthusiasts! 🚀
Ever been all set to launch your brand-new Flutter app on your Android device, only to be greeted by a frustrating SDK version error? 🤦♂️ It's like trying to plug in your headphones and realizing they don't fit - a real buzzkill! But don't worry, you're not alone. Many of us have faced this head-scratching situation, scratching our heads and wondering what in the world just went wrong. Fear not, as I'm here to shed some light on this pesky '[INSTALL_FAILED_OLDER_SDK: Requires newer sdk version #33 (current version is #31)]' error and guide you through the labyrinth of SDK versions. Let's dive in and decode this puzzle together, shall we? 💡
Firstly, this error can pop up if the compiled app was built against an older SDK version, and the Android device you are trying to run it on is equipped with a more recent SDK version. It's like trying to fit a square peg into a round hole - the mismatch just doesn't bode well for a smooth run. Secondly, you might encounter the same error if your Android device is lagging behind in terms of the SDK version, while your compiled app is all set for the latest SDK version. Think of it as trying to play a cutting-edge video game on an ancient console - the tech just isn't compatible! Understanding these two potential triggers is crucial in navigating your way through this perplexing roadblock.
How to Fix
Update Android SDK and Re-Build App
The most likely reason your app won't run on your device is because the SDK the app was built on is older than the SDK your device is running. This usually occurs when a new Android SDK is released and your device updates before you realize you need to obtain a copy of the new SDK.
In this scenario, the fix is very easy. Open up, Android Studio and navigate to settings. Here's a screenshot on a mac:
Once the settings window opens, you will see a list options on your left. Look for Appearance & Behavior, and then click on System Settings to expand the list, and finally click on Android SDK. Under the SDK Platforms tab, make sure the target version you need is clicked. Sometimes the check might be a horizontal line (or minus bar), which indicates that there are updates available for the SDK. If you see a horiztonal line instead of a check mark, click on it to turn it into a check mark. This will mark the SDK for updating. When the required SDKs have been checked, click apply and your SDKs will start downloading.
Once you have the SDKs downloaded, we need to update the gradle configuration in your flutter project. Navigate to android > app > build.gradle and open the gradle file.
In the build.gradle file, look for the line that has compileSdkVersion. You may see that compileSdkVersion is set to flutter.compileSdkVersion. Change this to the SDK target version number you wish to build for. There are other version settings you can update, such as minSdkVersion and targetSdkVersion
Additionally, instead of replacing the SDK version with a hard-coded number, you can alternatively update your flutter SDK package to use the new SDK versions. You can learn more about this in the following Stack Overflow post: Flutter : How to change Android minSdkVersion in Flutter Project?.
Downgrade Android SDK to Match your Android Device
If upgrading your SDK and building against the new version doesn't resolve this issue, it's possible that your Android device is running on an older version of the SDK. You can check this by going to your device's settings and check the build number. If your device SDK is older than the SDK your app is being built for, then you can either upgrade your device to the newest version (if that is feasible...some older devices may not support the newer Android SDK), or alternatively you can downgrade the SDK you are using to build your app. To do this, follow the same steps in the previous section but instead of click on a newer SDK, look for the SDK that matches your device and download that through Android Studio. Once the download has completed, don't forget to update your build.gradle file.
That's a Wrap, Folks! 🎬
Phew! Dealing with these SDK version mishaps might have felt like navigating a maze, but now you're armed with the know-how to troubleshoot them like a pro! Remember, ensuring that your app's SDK version aligns with your device's SDK version is the key to a seamless and hassle-free deployment. So, whether it's an outdated SDK causing trouble or a mismatch between your app and your device, you've got the tools to tackle it head-on. Now, go forth and let your Flutter app shine on every compatible Android device out there! Happy coding! 🌟
A Framework Built to Accelerate App Development for Startups
Kenneth Hough
Background
I founded KeyQ in March of 2020 with the vision of helping businesses achieve the next level of success through delivering innovative and meaningful cloud solutions. Since its inception, I have worked with several businesses, non-profit organizations, and universities to design and build cloud applications that have helped streamline their business processes and reduce costs.
Prior to KeyQ, I was a medical researcher at the University of Alabama at Birmingham (UAB) in the Division of Pulmonary, Allergy, and Critical Care Medicine. UAB is also where I worked on my doctoral thesis under the mentorship of Dr. Jessy Deshane and Dr. Victor Thannickal. During my doctoral work at UAB I was exposed to the “omics” and big data, which has influenced my career choice to develop data-driven analytics platforms in the cloud.
I also have to give a big shoutout to my undergraduate education at Worcester Polytechnic Institute (WPI), where I majored in biochemistry. WPI’s motto is “Lehr und Kunst,” which roughly translates to “Theory and Practice” or “Learning and Skilled Art.” WPI truly cherishes and upholds this pedagogy, which can be seen by the teaching styles and class sizes. The learning experience I had at WPI is unique and has shaped me to be who I am, being able to learn, practice and apply.
Personal Interests
I love to learn innovative technologies and try new things. I have a broad area of interests that include serverless architectures, machine learning, artificial intelligence, bioinformatics, medical informatics, and financial technology. I am also working towards my CFA level 1 exam for 2021. Other interests and hobbies include traveling, rock climbing, rappelling, caving, camping and gardening!