我正在尝试为一个使用蓝牙通信的应用程序启动一个颤振项目。我用的是颤振蓝。
不幸的是,当试图运行(在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与颤振,以及如何?
添加以下行到android/local。属性文件:
flutter.versionCode=1
flutter.versionName=0.0.1
flutter.flutterMinSdkVersion=24
flutter.flutterTargetSdkVersion=31
在android/app/build.gradle文件的"def versionName ="后面添加以下代码行:
def flutterMinSdkVersion = localProperties.getProperty('flutter.flutterMinSdkVersion')
if (flutterMinSdkVersion == null) {
flutterMinSdkVersion = '16'
}
def flutterTargetSdkVersion = localProperties.getProperty('flutter.flutterTargetSdkVersion')
if (flutterMinSdkVersion == null) {
flutterMinSdkVersion = '31'
}
最后编辑构建的部分。Gradle匹配如下:
defaultConfig {
applicationId "do.main.subdomain" // Use your App ID
minSdkVersion flutterMinSdkVersion.toInteger()
targetSdkVersion flutterTargetSdkVersion.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之后更改SdkVersion时,以下方式是最好的:
转到安装flutter的根目录。应该是这样的
C:\src\flutter\flutter
然后转到
packages>Flutter tools>gradle>
在Gradle中,你会看到很多文件,找到flutter。gradle。右键单击它,用文本编辑器/记事本编辑它。
在这里你可以找到所有的SDK版本。更改它们,保存,然后就可以开始了
完整的路径应该是这样的:(在我的例子中)
C:\src\flutter\flutter\packages\flutter_tools\gradle