'Gradle Build Failure version 7.1.3

I'm having trouble building my gradle file. I recently upgraded my gradle version form 7.1.2 on gradle-wrapper-properties, build.gradle files and added implementation 'com.android.tools.build:gradle:7.1.3' and see below error message when building with gradle:

Could not find com.android.tools.build:gradle:7.1.3. Searched in the following locations: - plugins.gradle.org/m2/com/android/tools/build/gradle/7.1.3/… If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration. Required by: project :app Add google Maven repository and sync project Open File

Below is my build.gradle(Project level) file :

apply '7.1.3'
buildscript {
    ext {
        agp_version = '7.1.3'
    }
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.14.0'
        classpath "com.android.tools.build:gradle:$agp_version"
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 31

    defaultConfig {
        applicationId "com.wallpapers_8k_Celebrity_Art.app"
        minSdkVersion 19
        targetSdkVersion 31
        versionCode 16
        versionName "alpha1.016"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.facebook.android:audience-network-sdk:6.8.0'
    implementation 'com.android.tools.build:gradle:7.1.3'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'com.google.firebase:firebase-database:20.0.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
    implementation 'com.applovin:applovin-sdk:+'
}

Updated properties file :

#Sun Apr 10 14:07:23 EAT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

Below is a screenshot under my project Structure setting : enter image description here



Solution 1:[1]

As this is a new version (released at 2022-04-08), you need google() repository for recent release, as stated in Android Developer Documentation

repositories {
    ...
    google()
}

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 samabcde