gpt4 book ai didi

Androidx 摄像头 : Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21

转载 作者:行者123 更新时间:2023-12-04 14:34:01 24 4
gpt4 key购买 nike

嗨,我正在使用 CameraX api 构建自定义相机,在将更新的库依赖项添加到 build.gradle 文件后,我收到以下构建错误

Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21 declared in library [androidx.camera:camera-extensions:1.0.0-alpha08] /Users/.gradle/caches/transforms-2/files-2.1/f20dc98c605a4c4dbd6030601f9665d3/camera-extensions-1.0.0-alpha08/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 21, or use tools:overrideLibrary="androidx.camera.extensions" to force usage (may lead to runtime failures)



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'

最佳答案

您可以通过将以下内容添加到 list 文件中来坚持使用最低版本 16。

<uses-sdk tools:overrideLibrary="androidx.camera.view, androidx.camera.camera2, androidx.camera.lifecycle, androidx.camera.core"/>

为避免运行时失败,您需要在使用 CameraX 之前检查设备是否在 api 21 及更高版本上运行
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
// Use camera2 or cameraX
}else{
// Use Camera1
}

关于Androidx 摄像头 : Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 21,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60476735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com