新建的flutter项目运行提示错误
android {
compileSdkVersion 34
...
}
与
android {
minSdkVersion 19
...
}
在 项目名\android\app\build.gradle
文件中只有flutter.compileSdkVersion
,项目搜索也找不到compileSdkVersion
解决办法:通过flutter sdk路径下的flutter.groovy文件修改compileSdkVersion 与 minSdkVersion
在最新版本中,路径已从flutter/packages/flutter_tools/gradle/flutter.gradle
改为
新路径:/flutter/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
默认值如下
class FlutterExtension {
/** Sets the compileSdkVersion used by default in Flutter app projects. */
static int compileSdkVersion = 33
/** Sets the minSdkVersion used by default in Flutter app projects. */
static int minSdkVersion = 19
/**
* Sets the targetSdkVersion used by default in Flutter app projects.
* targetSdkVersion should always be the latest available stable version.
*
* See https://developer.android.com/guide/topics/manifest/uses-sdk-element.
*/
static int targetSdkVersion = 33
/**
* Sets the ndkVersion used by default in Flutter app projects.
* Chosen as default version of the AGP version below as found in
* https://developer.android.com/studio/projects/install-ndk#default-ndk-per-agp.
*/
static String ndkVersion = "23.1.7779620"
/**
* Specifies the relative directory to the Flutter project directory.
* In an app project, this is ../.. since the app's build.gradle is under android/app.
*/
String source
/** Allows to override the target file. Otherwise, the target is lib/main.dart. */
String target
}
原文地址:点击跳转