1

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?

fabiobh
  • 705
  • 2
  • 13
  • 33
  • 1
    ***jcenter()*** has been deprecated; please use ***mavenCentral()*** https://developer.android.com/studio/build/jcenter-migration – ecle Oct 18 '22 at 04:51
  • I start to use mavenCentral(), but this was not the cause of the problem – fabiobh Oct 19 '22 at 15:55

1 Answers1

0

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

fabiobh
  • 705
  • 2
  • 13
  • 33
  • There is nothing wrong with the dependency syntax to use. Maybe it previously failed to connect to the remote repository. https://stackoverflow.com/a/35552666/980521 – ecle Oct 18 '22 at 04:57
  • I don't know what happened, but it only works if I use "implementation group" text – fabiobh Oct 19 '22 at 15:54