Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't use Android library after migration from JCenter to MavenCentral. Error: Could not find :unspecified:

I've just migrated my Android lib from JCenter to MavenCentral. The process completed successfully and I can find my lib through Sonatype Repo Search.

However, when I try to use the lib in my sample application, I get the following error:

Execution failed for task ':sample:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':sample:debugRuntimeClasspath'.
   > Could not find :unspecified:.
     Required by:
         project :sample > com.techyourchance:threadposter:1.0.0

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

It looks like Gradle finds my lib (because if I change to a non-existent version, say 2.0.0, then I get completely different error), but there is some problem with the artifact.

All the source code (both the lib and the sample app) can be found here. Specifically, here is build.gradle of the lib and that's the additional Gradle script that handles publication to Sonatype.

I've already spent two hours searching for each of the above error messages on the internet, but couldn't solve this issue so far.

like image 434
Vasiliy Avatar asked Apr 07 '21 17:04

Vasiliy


People also ask

What can I use instead of JCenter?

Migrating your app away from JCenter can be done by replacing all jcenter() references with mavenCentral() and adding explicit inclusions for dependencies that haven't migrated yet. For your published libraries, try to migrate as soon as possible, and don't forget to also migrate all existing artifacts.

What is difference between JCenter and mavenCentral?

Jcenter is a superset of mavenCentral, including many additional jars. Jcenter performance is better than mavenCentral. mavenCentral will automatically download many IDE-related indexes, and these are used less often which are not required.

What is JCenter in gradle?

JCenter Android. jCenter is the public repository hosted at bintray that is free to use for open source library publishers. It is the largest repository in the world for Java and Android OSS libraries, packages and components. All the content in JCenter is served over a CDN, with a secure HTTPS connection.


1 Answers

Skip dependencies with name 'unspecified' in your publish-maven.gradle.

withXml {
    def dependenciesNode = asNode().appendNode('dependencies')

    project.configurations.implementation.allDependencies.each {
        if (it.name != 'unspecified') {
            def dependencyNode = dependenciesNode.appendNode('dependency')
            dependencyNode.appendNode('groupId', it.group)
            dependencyNode.appendNode('artifactId', it.name)
            dependencyNode.appendNode('version', it.version)
        }
    }
}
like image 68
Artur Artikov Avatar answered Oct 30 '22 03:10

Artur Artikov