Flutter开发报错uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library

在这里插入图片描述

问题描述

今天导入一个新项目时报错,报错内容如下:

uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:wakelock_plus]

完整报错如下:

D:\WORK\myLearningWork\development\storetest\android\app\src\debug\AndroidManifest.xml Error:
	uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:wakelock_plus] D:\WORK\myLearningWork\development\storetest\build\wakelock_plus\intermediates\merged_manifest\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="dev.fluttercommunity.plus.wakelock" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:wakelock_plus] D:\WORK\myLearningWork\development\storetest\build\wakelock_plus\intermediates\merged_manifest\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="dev.fluttercommunity.plus.wakelock" to force usage (may lead to runtime failures)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 26s

如图:
在这里插入图片描述

问题原因

SDK版本太低导致的。

解决方法

修改build.gradle文件的配置
D:\WORK\myLearningWork\development\storetest\android\app\build.gradle

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.storetest"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

将minSdkVersion 改为19即可。

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.storetest"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 19
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

你可能感兴趣的:(Flutter,flutter,minSdkVersion)