'Failed to resolve library after upgrading the build version to 7.0

I have upgraded the my exiting project Gradle version from older version to "com.android.tools.build:gradle:7.0.4".

After upgrading the build version some of the existing libraries not working.

I got an error like below:

Failed to resolve: com.yarolegovich:discrete-scrollview:1.5.1 Show in Project Structure dialog Affected Modules: app

Failed to resolve: com.redmadrobot:input-mask-android:6.0.0 Show in Project Structure dialog Affected Modules: app

Failed to resolve: gun0912.ted:tedpermission:2.2.3 Show in Project Structure dialog Affected Modules: app

Failed to resolve: com.theartofdev.edmodo:android-image-cropper:2.8.0 Show in Project Structure dialog Affected Modules: app

Failed to resolve: com.wang.avi:library:2.1.3 Show in Project Structure dialog Affected Modules: app

We recommend using a newer Android Gradle plugin to use compileSdk = 32

This Android Gradle plugin (7.0.4) was tested up to compileSdk = 31

This warning can be suppressed by adding android.suppressUnsupportedCompileSdk=32 to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to use a newer Android Gradle Plugin that has been tested with compileSdk = 32 Affected Modules: app

Please help me to get out this error.

Thanks in advance.



Solution 1:[1]

in your build.gradle.app file there must be property called compileSdk which could be 31 or 32. change it to smaller values and try again.

Solution 2:[2]

I had the same problem. But I just run the project and it ran without any problems. But the errors still persist. I think the problem is with Android Studio cache. However, we have to wait until the next update.

Solution 3:[3]

Step 1: Update the Gradle version & all libraries.

Step 2: Remove allprojects { } from project-level build.gradle file.

Step 3: Replace project-level repositories {} with below code

repositories {
    maven {
        url "PROJECT DEPENDENCY URL" Ex. : https://maven.google.com, https://jitpack.io
    }
    google()
    mavenCentral()
    gradlePluginPortal()
}

Step 4: Same repositories {} code we have to add in settings.gradle file like below:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        maven {
            url "PROJECT DEPENDENCY URL" Ex. : https://maven.google.com, https://jitpack.io
        }
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

Step 5: Sync Gradle, clean the project & run.

I hope these steps will help you to upgrade the project from the old Gradle version to the new Gradle version 7.0.+.

Solution 4:[4]

Add jcenter() in your project level build.gradle like below

allprojects {
repositories {
    jcenter()
}}

and

buildscript {
   repositories {      
    jcenter()
}
dependencies {...}}

hope it works, as some of the libraries still in Jcenter()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mordor619
Solution 2 mohsen khorasani
Solution 3 Ravi Makvana
Solution 4 Rahul