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

不幸的是,当试图运行(在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与颤振,以及如何?


当前回答

你可以找到文件夹颤振(在MAC或Linux)或在Windows,你可以在这里看https://stackoverflow.com/a/304447/8122500。 然后你可以跟随@francis-nduba-numbi的指导。

有两种类型可以改变

从颤振。Gradle(建议在这里更改为不指定的/将来的) 或者直接从构建。Gradle(不推荐)

其他回答

这工作。使用新版本,现在可以直接从IDE更改它。 https://www.youtube.com/watch?v=ztjCMzBX18w

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应用程序中设置Auth0、flutter_appauth和flutter_secure_storage时遇到了这个问题。在更改minSdkVersion版本后,我得到了这个错误

C:\Users\myusername\AndroidStudioProjects\wole\android\app\src\debug\AndroidManifest.xml Error:
    Attribute data@scheme at AndroidManifest.xml requires a placeholder substitution but no value for <appAuthRedirectScheme> is provided.
FAILURE: Build failed with an exception.

问题出在哪里: 任务“:app:processDebugManifest”执行失败。

清单合并失败:AndroidManifest.xml中的属性data@scheme需要占位符替换,但没有提供for的值。

解决方案就是这样添加manifest占位符

从Flutter 2.8开始,设置minSdkVersion, targetSdkVersion和compileSdkVersion略有不同。现在gradle文件在your_flutter_app/android/app/build。Gradle路径是这样的:

只需将当前值替换为您想要的版本号,如下所示:

现在运行你的颤振项目,就这样。

你可以在Project_Name/android/app/build文件中修改minSdkVersion。Gradle, defaultconfig:

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.projectname"
    minSdkVersion 16 // <--- There
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}