android Flutter项目中“flutter.minSdkVersion”的值初始化在哪里?

ipakzgxi  于 2022-12-28  发布在  Android
关注(0)|答案(3)|浏览(312)

我已经创建了一个新的Flutter项目,minSdkVersion在app/build.gradle文件中的外观如下:

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.projectname"
    minSdkVersion flutter.minSdkVersion
    targetSdkVersion flutter.targetSdkVersion
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

flutter.minSdkVersion的值设置在哪里?
请注意,以前的配置值如下所示:

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.projectname"
    minSdkVersion 19 //*** This is the part that needs to be changed, previously was 16
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

另外,这是android/local.properties文件的内容:

sdk.dir=/Users/usernaem/Library/Android/sdk
flutter.sdk=/Users/username/flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.versionCode=1

正如您所看到的,flutter.minSdkVersion的值没有在那里设置,但是可以成功地编译和构建项目。
变量flutter.minSdkVersionflutter.targetSdkVersion在哪里初始化?
P.S.相关问题:https://github.com/flutter/flutter/issues/95533

juud5qan

juud5qan1#

转到flutter解压文件夹中的以下文件:
flutter/封装/flutter_工具/gradle/flutter.gradle
在那里你可以找到所有的静态变量。

pobjuy32

pobjuy322#

android/local.propertie文件中输入变量:
示例:

flutter.minSdkVersion=21

以及android/app/build.gradle的变化

localProperties.getProperties('flutter.minSdkVersion') // flutter.minSdkVersion
insrf1ej

insrf1ej3#

只需将flutter.minSdkVersion替换为所需的值,如旧样式的19

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.projectname"
    minSdkVersion 19
    targetSdkVersion flutter.targetSdkVersion
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

相关问题