Search code examples
androidandroidxandroid-camerax

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


Hi I am using CameraX api to build custom camera, after adding updated library dependency to build.gradle file, i am getting following build error


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 file

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'

Solution

  • Update your app.gradle minSdkVersion

    from:

     minSdkVersion 16
    

    to:

    minSdkVersion 21