如何在Flutter项目中更改Android minSdkVersion [英] How to change Android minSdkVersion in flutter project

查看:1952
本文介绍了如何在Flutter项目中更改Android minSdkVersion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试启动一个使用蓝牙进行通信的App的Flutter项目.为此,我使用的是颤动蓝色.

I was trying to start a flutter project for an App using bluetooth to communicate. For that, I was using flutter blue.

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

Unfortunately, when trying to run (on an Android device) the first example I created I was met with the following error:

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的性能,但是在一个杂乱无章的项目(使用VSCode)中,我有点迷失了.

If I were on Android Studio, I'd know how to bump up the Android minSdkVersion, but on a flutter project (using VSCode) I was a little lost.

是否有可能随着颤动而增加minSdkVersion?

Is it possible to increase the minSdkVersion with flutter, and how?

推荐答案

确实有可能增加minSdkVersion,但花了我太多的时间才能找到答案,因为google搜索主要是关于绝对最小Sdk结果讨论版本flutter应该能够支持,而不是如何在您自己的项目中增加它.

It is indeed possible to increase minSdkVersion, but it took me way too much time to find it out because google searches mostly yields as result discussions about the absolute minimum Sdk version flutter should be able to support, not how to increase it in your own project.

就像在Android Studio项目中一样,您必须编辑build.gradle文件.在flutter项目中,可以在路径./android/app/build.gradle中找到它.

Like in an Android Studio project, you have to edit the build.gradle file. In a flutter project, it is found at the path ./android/app/build.gradle.

当然,需要更改的参数是minSdkVersion 16,将其增加到所需的值(在本例中为19).

The parameter that needs to be changed is, of course, minSdkVersion 16, bumping it up to what you need (in this case 19).

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"
}

现在似乎很明显,但花了我足够长的时间自己解决.

Seems obvious now, but took me long enough to figure it out on my own.

这篇关于如何在Flutter项目中更改Android minSdkVersion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆