【发布时间】:2022-08-09 02:56:40
【问题描述】:
如果我在 build.gradle 中设置compileSdkVersion 33,就可以了。
但它是一种硬代码,所以我尝试将它设置在local.properties 文件中。
由于我已经在该文件中设置了flutter.minSdkVersion=23,我认为flutter.compileSdkVersion=33 的工作方式相同,但事实并非如此。
细节:
local.properties 文件:
flutter.compileSdkVersion=33
build.gradle 文件:
def flutterCompileSdkVersion = localProperties.getProperty(\'flutter.compileSdkVersion\')
if (flutterCompileSdkVersion == null) {
flutterCompileSdkVersion = flutter.compileSdkVersion
}
...
compileSdkVersion flutterCompileSdkVersion // error here
compileSdkVersion 33 // this works
错误信息:
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
无论如何要在 local.properties 文件中设置 compileSdkVersion 吗?