While building flutter app, I am getting this error.
One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to C:\flutter\projects\my_app\android\app\build.gradle:
android {
compileSdkVersion 33
...
}
However, in my build.gradle I have :
android {
compileSdkVersion flutter.compileSdkVersion
...
}
But I am unable to find the location where flutter.compileSdkVersion is defined. Any idea where is this defined? I have already run flutter upgrade and flutter --version returns Flutter 3.0.5.
CodePudding user response:
The setting that you might wonder where it comes from is in the flutter installation directory here:
<flutter-installation>\packages\flutter_tools\gradle\flutter.gradle
If you want to have the settings gathered in one place, then you could set it in the file local.properties
as:
flutter.compileSdkVersion=33
And you change in your build.gradle in the following way:
android {
compileSdkVersion localProperties.getProperty('flutter.compileSdkVersion').toInteger()
...
}
or (obviously) just set the version direct as:
android {
compileSdkVersion 33
...
}
CodePudding user response:
Open the android folder. open the App folder. open the build.gradle from app folder.
CodePudding user response:
flutter.compileSdkVersion is the default version that defaults to installed flutter version configs. You can replace flutter.compileSdkVersion to your own custom version.
CodePudding user response:
yes, and there you need to change it. replace:
android {
compileSdkVersion flutter.compileSdkVersion
...
}
with this:
android {
compileSdkVersion 33
...
}
flutter.compileSdkVersion
just the default one got from the flutter sdk.
CodePudding user response:
Every flutter version has a compiledSdkVersion property along with others. As of Flutter 3.3.8, it is 31.
You can access the code here https://chromium.googlesource.com/external/github.com/flutter/flutter/ /refs/heads/dev/packages/flutter_tools/gradle/flutter.gradle#33
In future it might be more than 33. In case you hardcode value as 33, flutter might stop building with errors.
So the solution should be
compileSdkVersion Math.max(flutter.compileSdkVersion, 33)
now, in future if flutter changes the property to say 35, your code won't break.