天天看點

【錯誤記錄】Android 應用導入 ijkplayer 報錯 ( uses-sdk:minSdkVersion 19 cannot be smaller than version 21 decl )

文章目錄

  • ​​一、報錯資訊​​
  • ​​二、解決方案​​
  • ​​方案一​​
  • ​​方案二​​

一、報錯資訊

在 Android 應用中 , 使用 ijkplayer , 如果在 build.gradle 中配置了 abiFilters 如下架構

android {
    defaultConfig {
        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a" 
        }
    }
}      

打包 so 動态庫時 , 就會打包 “armeabi-v7a”, “arm64-v8a” 這兩個架構的動态庫 ,

如果要導入 arm64 架構的動态庫 , 則需要導入

implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'      

動态庫 , 則報如下錯誤 :

> Task :APP_MIDI:processDebugMainManifest FAILED
[com.android.support:animated-vector-drawable:28.0.0] C:\Users\octop\.gradle\caches\transforms-2\files-2.1\3834af447b012165d7b2b5f1ce55daf8\animated-vector-drawable-28.0.0\AndroidManifest.xml Warning:
  Package name 'android.support.graphics.drawable' used in: com.android.support:animated-vector-drawable:28.0.0, com.android.support:support-vector-drawable:28.0.0.
Y:\002_WorkSpace\000_Android_Work\MIDI_TV_GooglePlay_100M_APK\MIDI_TV\APP_MIDI\src\main\AndroidManifest.xml Error:
  uses-sdk:minSdkVersion 19 cannot be smaller than version 21 declared in library [tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8] C:\Users\octop\.gradle\caches\transforms-2\files-2.1\3fe1eab93e41ce9151c23d920db28b32\ijkplayer-arm64-0.8.8\AndroidManifest.xml as the library might be using APIs not available in 19
  Suggestion: use a compatible library with a minSdk of at most 19,
    or increase this project's minSdk version to at least 21,
    or use tools:overrideLibrary="tv.danmaku.ijk.media.player_arm64" to force usage (may lead to runtime failures)

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


> Task :APP_MIDI:checkDebugAarMetadata      
【錯誤記錄】Android 應用導入 ijkplayer 報錯 ( uses-sdk:minSdkVersion 19 cannot be smaller than version 21 decl )

二、解決方案

在報錯中 , 給出了 種修改方案 :

Suggestion: use a compatible library with a minSdk of at most 19,
    or increase this project's minSdk version to at least 21,
    or use tools:overrideLibrary="tv.danmaku.ijk.media.player_arm64" to force usage (may lead to runtime failures)      

方案一

在 build.gradle 中配置 android # defaultConfig # minSdkVersion 為 ;

android {
    compileSdkVersion 30
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "com.example.app"
        minSdkVersion 19
    }
}      

方案二

<uses-sdk
        xmlns:tools="http://schemas.android.com/tools"
        tools:overrideLibrary="tv.danmaku.ijk.media.player_arm64"/>      
version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.app"
    android:installLocation="auto">
    
    <uses-sdk
        xmlns:tools="http://schemas.android.com/tools"
        tools:overrideLibrary="tv.danmaku.ijk.media.player_arm64"/>

manifest>