'Gradle Building Error while outputting the program

I am facing an issue when I am Using Gradle to output my Android APP in Android Studio, I am getting such error, the error was there in sync, then I tried to sync and the AVD was working, and the sync worked, but now, maybe I face the same issue while using Gradle to output, and I think this might help, that I reset my laptop, so everything is removed, and I reinstalled Android Studio and everything, and this is my first test, and run for Gradle too.

Here is my build.gradle which I get

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.5.10"
    repositories {
        google()
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5"
        classpath "org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.10"
 
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
 
allprojects {
    repositories {
        google()
    }
}
 
task clean(type: Delete) {
    delete rootProject.buildDir
}

Here is my error

    Could not determine the dependencies of task ':app:kaptDebugKotlin'.

> Could not resolve all files for configuration ':app:kotlinKaptWorkerDependencies'.

> Could not find org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.10.

Searched in the following locations:

- https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-annotation-processing-gradle/1.5.10/kotlin-annotation-processing-gradle-1.5.10.pom

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



Possible solution:

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

Who could help, that would be appreciated and would be happy, thank you...



Solution 1:[1]

Add central Maven repository

repositories {
    mavenCentral()
}

Possible cause of error :
It seems currently android studio is trying to download library( org.jetbrains.kotlin:kotlin-annotation-processing-gradle:1.5.10) from location "https://dl.google.com/dl/android/maven2" , but for some reason it couldn't find pom file as explained in the error.
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.

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 Nitish