uses-sdk:minSdkVersion 16 不能小于库 [:audioplayers] 中声明的版本 23

Posted

技术标签:

【中文标题】uses-sdk:minSdkVersion 16 不能小于库 [:audioplayers] 中声明的版本 23【英文标题】:uses-sdk:minSdkVersion 16 cannot be smaller than version 23 declared in library [:audioplayers] 【发布时间】:2021-05-15 22:08:51 【问题描述】:

我正在用颤振、飞镖和火焰创建一个简单的游戏,我的火焰更新版本与颤动相同,

C:\Users\Users\Desktop\vcflutter\flutter_application_1\lib\Flutter Game\flutter_application_1\android\app\src\debug\AndroidManifest.xml Error:
    uses-sdk:minSdkVersion 16 cannot be smaller than version 23 declared in library [:audioplayers] C:\Users\Users\Desktop\vcflutter\flutter_application_1\lib\Flutter Game\flutter_application_1\build\audioplayers\intermediates\library_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 23,
        or use tools:overrideLibrary="xyz.luan.audioplayers" to force usage (may lead to runtime failures)

我的 pubspec.yaml

version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flame: ^0.29.0
  cupertino_icons: ^1.0.0

dev_dependencies:
  flutter_test:
    sdk: flutter

我的 main.dart

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flame/util.dart';
import 'package:flutter/services.dart';
import 'package:flutter_application_1/langaw-game.dart';

void main() async 
  WidgetsFlutterBinding.ensureInitialized();
  Util flameUtil = Util();
  await flameUtil.fullScreen();
  await flameUtil.setOrientation(DeviceOrientation.portraitUp);

  LangawGame game = LangawGame();
  runApp(game.widget);

langaw-game.dart

import 'dart:ui';
import 'package:flame/game.dart';

class LangawGame extends Game 
  Size screenSize;
  double tileSize;
  @override
  void render(Canvas canvas) 
    Rect bgRect = Rect.fromLTWH(0, 0, screenSize.width, screenSize.height);
    Paint bgPaint = Paint();
    bgPaint.color = Color(0xff576574);
    canvas.drawRect(bgRect, bgPaint);
  

  @override
  void update(double t) 
  @override
  void resize(Size size) 
    super.resize(size);
    screenSize = size;
    tileSize = screenSize.width / 9;
  

我在 youtube 上关注此文档https://www.youtube.com/watch?v=N4LFV9_fLAo

【问题讨论】:

【参考方案1】:

在您的 gradle 文件中,只需将 minSdkVersion 更新为 23

android 
compileSdkVersion 30
defaultConfig 
    applicationId "com.oaics.customer"
    minSdkVersion 23
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"
   

【讨论】:

【参考方案2】:

这是一个技巧(避免标题问题)

使用

<uses-sdk tools:overrideLibrary="xyz.luan.audioplayers"/>

除此之外,将此添加到manifest 标签:

xmlns:tools="http://schemas.android.com/tools"

文件总内容:

<!-- Generated file. Do not edit. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="nct.mobile.flutter.module"
    xmlns:tools="http://schemas.android.com/tools">
  <uses-permission android:name="android.permission.INTERNET"/>

  <!--
  Issue : https://***.com/questions/66167083/uses-sdkminsdkversion-16-cannot-be-smaller-than-version-23-declared-in-library
  Docs : https://***.com/questions/27095077/how-do-i-use-toolsoverridelibrary-in-a-build-gradle-file
   -->
  <uses-sdk tools:overrideLibrary="xyz.luan.audioplayers, io.flutter.plugins.pathprovider"/>

  <application tools:node="merge">
    <meta-data
      android:name="flutterProjectType"
      android:value="module" />
      <!-- Don't delete the meta-data below.
           It is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
      <meta-data
          android:name="flutterEmbedding"
          android:value="2" />
  </application>
</manifest>

【讨论】:

以上是关于uses-sdk:minSdkVersion 16 不能小于库 [:audioplayers] 中声明的版本 23的主要内容,如果未能解决你的问题,请参考以下文章

uses-sdk:minSdkVersion 16 不能小于库 [:audioplayers] 中声明的版本 23

flutter_smart_cropper uses-sdk:minSdkVersion 16 不能小于库中声明的版本 19

关于Manifest merger failed : uses-sdk:minSdkVersion 8 cannot be smaller than version 16 declared in li

Manifest merger failed:uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in libra

Android Studio 错误:清单合并失败:uses-sdk:minSdkVersion

清单合并失败:uses-sdk:minSdkVersion 14