Unable to install GitLab Maven Package Registry using Gradle

Hi everyone,
I have created a GitLab Maven Package Registry. In the build.gradle of the library module for which I have created the Maven Package Registry, I have added the publishing content like this:

publishing {
    publications {
        create<MavenPublication>("fancytoaster") { // Use components["java"] to reference the Java component
            groupId = "com.gitlab.afaqrehman98"// Replace with your group ID
            artifactId = "fancytoaster" as String// Replace with your artifact ID
            version = "1.0.0" // Replace with your version
    repositories {
        maven {
            url = uri("https://gitlab.com/api/v4/projects/PROJECT_ID/packages/maven")
            credentials(HttpHeaderCredentials::class) {
                name = "Authorization"
                value = "Bearer ${findProperty("gitLabPrivateToken") as String?}"
            authentication {
                create("header", HttpHeaderAuthentication::class)

In the consuming project, where I want to use the Package Registry as a dependency, I have added the dependency in the app level build.gradle like this:

dependencies {

and in the repositories block inside the settings.gradle I have added the maven URL like this:


But still, after syncing, I am unable to get the desired method from the Package Registry.

The GitLab repo is the following: