我正在尝试为一个使用蓝牙通信的应用程序启动一个颤振项目。我用的是颤振蓝。

不幸的是,当试图运行(在Android设备上)我创建的第一个示例时,我遇到了以下错误:

FAILURE: Build failed with an exception.

  * What went wrong:
  Execution failed for task ':app:processDebugManifest'.
  > Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:flutter_blue] /home/maldus/Projects/flutter/polmac/build/flutter_blue/intermediates/manifests/full/debug/AndroidManifest.xml as the library might be using APIs not available in 16
    Suggestion: use a compatible library with a minSdk of at most 16,
            or increase this project's minSdk version to at least 19,
            or use tools:overrideLibrary="com.pauldemarco.flutterblue" to force usage (may lead to runtime failures)

如果我在Android Studio,我知道如何提升Android minSdkVersion,但在一个flutter项目(使用VSCode),我有点迷失。

是否有可能增加minSdkVersion与颤振,以及如何?


当前回答

2.8或以上

构建。gradle更新

在更新到Flutter 2.8之前

android {
    compileSdkVersion 30

defaultConfig {
    applicationId "com.example.app"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    multiDexEnabled true
}

更新到Flutter 2.8后:

android {
    compileSdkVersion flutter.compileSdkVersion

defaultConfig {
        applicationId "com.example.app"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

你应该从慢车转车。以下属性说明:

首先进入android->local.properties

从这里开始变化

像这样改变build.gradle

android {
    compileSdkVersion localProperties.getProperty('flutter.compileSdkVersion').toInteger()

defaultConfig {
    minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
    targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

其他回答

我发现解决这个问题的最好方法是通过改变颤振的设置,让它在未来的所有应用程序中都能全局执行。Gradle文件位于您的默认构建部分。如果你使用VSCode

转到此位置(或已安装颤振的位置) C: \ src \ flutter_tools \ gradle \ \颤振\包 拖动颤振。gradle文件到VSCode 更新最小值、编译和/或目标版本 保存

2.8或以上

构建。gradle更新

在更新到Flutter 2.8之前

android {
    compileSdkVersion 30

defaultConfig {
    applicationId "com.example.app"
    minSdkVersion 21
    targetSdkVersion 30
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    multiDexEnabled true
}

更新到Flutter 2.8后:

android {
    compileSdkVersion flutter.compileSdkVersion

defaultConfig {
        applicationId "com.example.app"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

你应该从慢车转车。以下属性说明:

首先进入android->local.properties

从这里开始变化

像这样改变build.gradle

android {
    compileSdkVersion localProperties.getProperty('flutter.compileSdkVersion').toInteger()

defaultConfig {
    minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
    targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

所有答案都是最好的。但在Flutter 2.8之后更改SdkVersion时,以下方式是最好的:

转到安装flutter的根目录。应该是这样的

C:\src\flutter\flutter

然后转到

packages>Flutter tools>gradle>

在Gradle中,你会看到很多文件,找到flutter。gradle。右键单击它,用文本编辑器/记事本编辑它。

在这里你可以找到所有的SDK版本。更改它们,保存,然后就可以开始了

完整的路径应该是这样的:(在我的例子中)

C:\src\flutter\flutter\packages\flutter_tools\gradle

对于颤振v2.8

在当地。属性添加

sdk.dir='<path>'
flutter.sdk='<path>'
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1

flutter.minSdkVersion=21
flutter.targetSdkVersion=30
flutter.compileSdkVersion=30

app-level build.gradle

defaultConfig {
    minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
    targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
}

现在可以使用localProperties.getProperty()从属性文件中读取值。

改变的地方。下面提到的属性文件..因为目前游戏商店更新最低目标API版本至少30

sdk.dir=/Users/sweetnandha/Library/Android/sdk
flutter.sdk=/Users/sweetnandha/FlutterDev/flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
flutter.compileSdkVersion=32
flutter.minSdkVersion=21
flutter.targetSdkVersion=32

or