'Invalid publication 'maven': multiple artifacts with the identical extension and classifier ('jar', 'sources')

Failed to publish publication 'maven' to repository 'GitHubPackages' Invalid publication 'maven': multiple artifacts with the identical extension and classifier ('jar', 'sources').

This error appeared when running GitHub Actions to publish my android library on GitHub Packages

Here is my code.

this is build.gradle(library)

android{
    publishing {
        singleVariant('release') {
            withSourcesJar()
            withJavadocJar()
        }
    }
}
afterEvaluate {
publishing {
    publications {
        maven(MavenPublication) {
            groupId mGroupId
            artifactId mArtifactId
            version mVersionName

            from components.release

            artifact androidSourcesJar

            pom {
                name = mLibraryName
                description = mLibraryDescription
            }
        }
    }

    // Update repository details and credentials.
        repositories {
            maven {
                name = "GitHubPackages"
                url = uri("https://maven.pkg.github.com/codebrust/andoid.library")
                credentials {
                    username = System.getenv("GITHUB_ACTOR")
                    password = System.getenv("GITHUB_TOKEN")
                }
            }
        }
    }
}

There is an error when publishing android library on GitHub-Packages



Sources

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

Source: Stack Overflow

Solution Source