Home > Back-end >  Could not resolve androidx.appcompat:appcompat:1.5.1 - Error with Gradle in Android Studio
Could not resolve androidx.appcompat:appcompat:1.5.1 - Error with Gradle in Android Studio

Time:10-20

I try to update my AppCompat library from 1.0.0 to 1.5.1 in the Gradle file and I got this error

Could not resolve androidx.appcompat:appcompat:1.5.1.
Required by:
    project :app

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

I try to update the library, but I always get errors.

This is the content of my Gradle file

buildscript {
ext {
    kotlin_version = '1.7.10'
}
repositories {
    jcenter()
    google()
    //maven { url 'https://maven.fabric.io/public' }
    //maven { url "https://maven.google.com" }
}
dependencies {
    classpath 'com.android.tools.build:gradle:7.2.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

    classpath 'com.google.gms:google-services:4.3.10'
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
       jcenter()
        google()
    }
}

How I can fix this error?

CodePudding user response:

I don't know why, but I try to use the code below

implementation group: 'com.google.android.material', name: 'material', version: '1.6.1' 

instead of

implementation 'com.google.android.material:material:1.0.0'

and it works for me now to import the last app compat library without problems

implementation 'androidx.appcompat:appcompat:1.5.1'

Now I was able to import the library without problems

  • Related