android 三方sdk minSdkVersion 兼容问题处理
在Android开发中,当应用引入的第三方库的minSdkVersion高于项目自身的minSdkVersion时,会导致编译错误。以下是几种常见的解决方案:
方案一
调整为与第三方库一致的版本
xml
defaultConfig {
minSdkVersion 21 // 调整为与第三方库一致的版本
targetSdkVersion 30
}
方案二
使用tools:overrideLibrary强制覆盖
xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-sdk tools:overrideLibrary="com.example.library" />
</manifest>
使用overrideLibrary
时需测试运行时行为,避免因API不兼容导致崩溃