嗨,我正在使用CameraX api来构建自定义相机,在将更新的库依赖项添加到build.gradle文件之后,我得到了以下构建错误消息
清单合并失败:uses-sdk:minSdkVersion 16不能小于在库[androidx.camera:camera-extensions:1.0.0-alpha08]中声明的版本21 /Users/.gradle/caches/transforms-2/files- 2.1 / f20dc98c605a4c4dbd6030601f9665d3 / camera-extensions-1.0.0-alpha08 / AndroidManifest.xml,因为该库可能使用的API在16中不可用建议:使用兼容的库,其minSdk最多为16,或将该项目的minSdk版本提高到至少21,或使用tools:overrideLibrary =“ androidx.camera.extensions”强制使用(可能导致运行时失败)
build.gradle文件
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId ""
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled = true
}
flavorDimensions 'dimensions'
productFlavors {
dev {
//assembleDevDebug crashlyticsUploadDistributionDevDebug
applicationId ""
versionName "D(0.0)" //for QA Release
versionCode 00
proguardFile("proguard-rules.pro")
}
prod {
applicationId ""
versionName "1.3" //for prod release
versionCode 13
proguardFile("proguard-rules.pro")
resValue "string", "app_name", "Prod Android"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "androidx.camera:camera-core:1.0.0-beta01"
implementation "androidx.camera:camera-camera2:1.0.0-beta01"
implementation "androidx.camera:camera-extensions:1.0.0-alpha08"
}
apply plugin: 'com.google.gms.google-services'
更新您的app.gradle minSdkVersion
来自:
minSdkVersion 16
至:
minSdkVersion 21