Gradle Failed to resolve : androidx.camera:camera2

Viewed 20

This is my first question on SOF.I have an assignment from school to build an android app that records videos. I have the challenge of getting the camera to work. I followed this tutorial, except for the build.gradle file part that I had to use different dependency versions, because gradle was giving me an error about not supported version of dependencies. Here is my build.gradle file:

plugins {
id 'com.android.application'
}

ext {
buildToolsVersion = '33.0.0'
}

android {
compileSdk 32

defaultConfig {
    applicationId "com.example.myapplication"
    minSdk 29
    targetSdk 32
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 
'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '33.0.0'
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
def camerax_version = "1.2.0-beta01"
implementation "androidx.camera:camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
implementation 'androidx.camera:camera-view:1.2.0-beta01'
implementation "androidx.camera:camera-extensions:$camerax_version"
}

But when I try to sync gradle, I'm getting this error message inside Build: Sync tab:

Failed to resolve: androidx.camera:camera2:1.2.0-beta01 Add Google Maven repository and sync project Show in Project Structure dialog Affected Modules: app

I tried resetting the Android studio by deleting the profile folder, that didn't help. Please someone help me with this. Thank you

Android Studio: 2021.2.1 patch 2 Gradle JDK: Embedded v. 11.0.12

1 Answers

You didn't get the artifact name right. Instead of:

implementation "androidx.camera:camera2:$camerax_version"

Do:

implementation "androidx.camera:camera-camera2:$camerax_version"

Related