Mal*_*dus 23 android android-sdk-tools flutter
我试图用一个使用蓝牙进行通信的App开始一个颤动的项目.为此,我使用的是蓝色.
不幸的是,当我尝试运行(在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)
Run Code Online (Sandbox Code Playgroud)
如果我在Android Studio上,我知道如何提升Android minSdkVersion,但是在一个颤动的项目上(使用VSCode)我有点迷失.
是否可以通过颤振增加minSdkVersion,以及如何?
Jah*_*lam 283
Flutter 2.8 或更高版本
build.gradle更新
更新到 Flutter 2.8 之前
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
Run Code Online (Sandbox Code Playgroud)
更新到 Flutter 2.8 后:
android {
compileSdkVersion flutter.compileSdkVersion
defaultConfig {
applicationId "com.example.app"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Run Code Online (Sandbox Code Playgroud)
您应该更改local.properties以下说明:
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
}
Run Code Online (Sandbox Code Playgroud)
Fra*_*mbi 175
如果您不知道,Google Playstore 只允许 minSdkVersion 为 20 或以上。但 flutter 仍然将默认的 minSdkVersion 设置为 16。您是否看到您总是必须为每个新项目手动更改?
您上面的所有建议都很好,但它们不是最好的,因为您将被迫为您创建的每个新项目调整build.gradle。
最好的方法是从源头修改全局 minSdkVersion 变量的值,这样所有项目,无论新的还是旧的,都会采用它。请记住flutter.minSdkVersion表示该变量位于flutter目录中(带有 sdk)。
有问题的文件是flutter.gradle。
地址是flutter-directory/packages/flutter_tools/gradle/flutter.gradle
class FlutterExtension {
/** Sets the compileSdkVersion used by default in Flutter app projects. */
static int compileSdkVersion = 31
/** Sets the minSdkVersion used by default in Flutter app projects. */
static int minSdkVersion = 16
/** Sets the targetSdkVersion used by default in Flutter app projects. */
static int targetSdkVersion = 31
Run Code Online (Sandbox Code Playgroud)
将 minSdkVersion 的值从 16 更改为 20 或以上,并且不要干扰build.gradle中的代码。
如果你愿意,你可以观看我在 Youtube 上制作的视频,解释如下:flutter 配置 minSdkVersion 从 16 到 20 或以上
=======================
由于 Flutter 3.13 及更高版本的更改而更新的响应
在此版本中,此文件flutter-directory/packages/flutter_tools/gradle/flutter.gradle的内容已移至此新位置flutter-directory/packages/flutter_tools/gradle/src/main/groovy/flutter.groovy。和默认的minSdkVersion = 19. 但为了安全地使用最新的软件包和 Android 设备,最好将其设置为minSdkVersion = 20.
Mr *_*dom 65
对于颤振 v2.8
在 local.properties 里面添加
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
Run Code Online (Sandbox Code Playgroud)
应用程序级 build.gradle
defaultConfig {
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Run Code Online (Sandbox Code Playgroud)
现在您可以用来localProperties.getProperty()从属性文件中读取值。
Mal*_*dus 50
确实有可能增加minSdkVersion,但是我花了太多时间才找到它,因为google搜索主要产生结果讨论关于绝对最小Sdk版本颤动应该能够支持,而不是如何在你自己的项目中增加它.
与在Android Studio项目中一样,您必须编辑该build.gradle文件.在一个颤动的项目中,它在路径上找到./android/app/build.gradle.
当然,需要更改的参数是将minSdkVersion 16其提升到您需要的值(在本例中为19).
现在似乎显而易见,但是我花了足够长的时间来自己解决这个问题.
小智 38
这里是更改MinSdk /Minsdk版本错误的详细解决方案,请按照步骤操作。
在 android\local.properties 上添加以下行
sdk.dir=
flutter.sdk=C:\\flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
flutter.minSdkVersion=21
flutter.targetSdkVersion=31
flutter.compileSdkVersion=31
Run Code Online (Sandbox Code Playgroud)
删除现有行并将其粘贴到应用程序级别 build.gradle:android\app\build.gradle
defaultConfig {
applicationId "app-id"
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Run Code Online (Sandbox Code Playgroud)
dph*_*ans 36
在新的 Flutter 项目 (2.8.0) 中,通过“Flutter 样式”,您可以在 local.properties 中更改最低 sdk 版本(而不是编辑 app/build.gradle 文件)。
# android/local.properties
flutter.minSdkVersion=19
Run Code Online (Sandbox Code Playgroud)
查看 android/app/build.gradle 文件,您将看到如下变量约束:
# android/app/build.gradle
android {
defaultConfig {
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
}
Run Code Online (Sandbox Code Playgroud)
Rog*_*sta 30
您可以更改minSdkVersion文件中的Project_Name/android/app/build.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"
}
Run Code Online (Sandbox Code Playgroud)
Gel*_*rge 26
将以下行添加到 android/local.properties 文件:
flutter.versionCode=1
flutter.versionName=0.0.1
flutter.flutterMinSdkVersion=24
flutter.flutterTargetSdkVersion=31
Run Code Online (Sandbox Code Playgroud)
在文件的顶层添加以下行,可能位于文件 android/app/build.gradle 中的“def versionName =”之后:
def flutterMinSdkVersion = localProperties.getProperty('flutter.flutterMinSdkVersion')
if (flutterMinSdkVersion == null) {
flutterMinSdkVersion = '16'
}
def flutterTargetSdkVersion = localProperties.getProperty('flutter.flutterTargetSdkVersion')
if (flutterTargetSdkVersion == null) {
flutterTargetSdkVersion = '31'
}
Run Code Online (Sandbox Code Playgroud)
最后编辑 build.gradle 中匹配的部分,如下所示:
defaultConfig {
applicationId "do.main.subdomain" // Use your App ID
minSdkVersion flutterMinSdkVersion.toInteger()
targetSdkVersion flutterTargetSdkVersion.toInteger()
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Run Code Online (Sandbox Code Playgroud)
完成所有这些后,您就可以开始了。下次您想要更新某些内容时,只需更改一个文件即可。
小智 15
All answers are best. But the following way is best in changing SdkVersion after Flutter 2.8 :
Go to your root directory where flutter is installed. It should be like
C:\src\flutter\flutter
Run Code Online (Sandbox Code Playgroud)
Then go to
packages>Flutter tools>gradle>
Run Code Online (Sandbox Code Playgroud)
In Gradle, you will see many files, locate flutter.gradle . Right-click on it and edit it with text editor/notepad.
here you will find all SDK versions. Change them, save, and then you are ready to go
the complete path should be like this: (in my case)
C:\src\flutter\flutter\packages\flutter_tools\gradle
Run Code Online (Sandbox Code Playgroud)
Min*_*Thu 11
对于MacBook M 系列芯片上的flutter 版本3.xx ,
要更改的 minSdkVersion 文件是
/flutter/packages/flutter_tools/gradle/src/main/groovy.flutter.groovy
Run Code Online (Sandbox Code Playgroud)
/flutter/packages/flutter_tools/gradle/src/main/groovy.flutter.groovy
Run Code Online (Sandbox Code Playgroud)
Rah*_*hul 10
这是我最近遇到这个问题时的处理方法:
里面<your-project>/android/app/build.gradle
找到 android -> defaultConfig -> minSdkVersion 并将其替换为
minSdkVersion Math.max(flutter.minSdkVersion, 21)
此处的 21 可以替换为您想要的任何最低版本。
如果 flutter 开始支持 23 或其他更高版本作为最低版本,并且您决定为您的项目升级 flutter,它仍然可以工作。
如果您的应用需要特定的最低 Android 平台版本,您可以将该版本要求指定为应用build.gradle文件中的 API 级别设置。在构建过程中,这些设置会合并到您应用的清单文件中。指定 API 级别要求可确保您的应用只能安装在运行兼容版本的 Android 平台的设备上。
您必须minSdkVersion在build.gradle文件中<app dir>/android/app 设置,位于 并在defaultConfig块中设置一个值 :
有两个 API 级别设置可用:
minSdkVersion — 运行应用程序的 Android 平台的最低版本,由平台的 API 级别标识符指定。targetSdkVersion — 指定应用程序旨在运行的 API 级别。在某些情况下,这允许应用使用在目标 API 级别中定义的清单元素或行为,而不是仅限于使用为最低 API 级别定义的元素或行为。要在build.gradle 文件中指定默认 API 级别要求 ,请将上述一项或多项设置添加到 defaultConfig {} 块中,嵌套在 android {} 块中。您还可以通过添加构建类型或产品风格的设置来覆盖不同版本的应用程序的这些默认值。以下 build.gradle 文件指定 块 中的默认值 minSdkVersion 和 targetSdkVersion设置 defaultConfig {}并覆盖 minSdkVersion 一种产品风味。
android {
compileSdkVersion 29
...
defaultConfig {
applicationId "com.app.yourapp"
minSdkVersion 16
targetSdkVersion 29
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
productFlavors {
main {
...
}
afterLollipop {
...
minSdkVersion 21
}
}
}
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅uses-sdk-element清单元素文档和API 级别文档。
小智 6
请按照以下步骤来改变minSdkVersion问题。
首先=>YouProject_name/android/app/build.gradle
Second=> defaultconfig { //你可以在里面找到它build.gradle}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.umair.product_details_using_crud"
minSdkVersion 16 // here you can change minSdkVersison
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Run Code Online (Sandbox Code Playgroud)
小智 6
**android/local.properties**
flutter.versionCode=1
flutter.minSdkVersion=21
flutter.targetSdkVersion=30
flutter.compileSdkVersion=31
**android/app/build.gradle**
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15960 次 |
| 最近记录: |