Reputation: 9092
If I set compileSdkVersion 33
in build.gradle, it's ok.
But it's kind of hard code, so I try to set it in local.properties
file.
As I already set flutter.minSdkVersion=23
in that file, I think flutter.compileSdkVersion=33
works the same, but it's not.
Details:
local.properties file:
flutter.compileSdkVersion=33
build.gradle file:
def flutterCompileSdkVersion = localProperties.getProperty('flutter.compileSdkVersion')
if (flutterCompileSdkVersion == null) {
flutterCompileSdkVersion = flutter.compileSdkVersion
}
...
compileSdkVersion flutterCompileSdkVersion // error here
compileSdkVersion 33 // this works
Error message:
FAILURE: Build failed with an exception.
* Where:
Script '/Users/vietstone-ng/Library/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 461
* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
> String index out of range: -6
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 785ms
Is there anyway to set compileSdkVersion inside local.properties file?
Upvotes: 6
Views: 6056
Reputation: 536
I was able to set it using local.properties this way:
// in YourProject/android/app/build.gradle
...
android {
compileSdkVersion localProperties.getProperty('flutter.compileSdkVersion').toInteger()
...
}
The following did not work
android {
compileSdkVersion flutter.compileSdkVersion
...
Originally answered by Maldus here
Upvotes: 12