Jing Li
Jing Li

Reputation: 15116

Error:Failed to resolve: org.mockito:mockito-core

When I tried to upgrade mockito for my Android project, from 2.8.47 to 2.13.3, I got an error:

Error:Failed to resolve: org.mockito:mockito-core:2.13.3

All my gradle configurations are correct, worked perfectly with 2.8.47 (below I just replace the mockito version with the latest one).

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url "https://maven.google.com"
        }
    }
}

ext {
    mockitoVersion = "2.13.3"
}

dependencies {
    testImplementation "org.mockito:mockito-core:${mockitoVersion}"
}

And when doing gradle sync, you can see at the bottom of Android Studio, there are some logs:

Gradle: Download https://maven.google.com/org/mockito/mockito-core/2.13.3/mockito-core-2.13.3.pom

Upvotes: 2

Views: 13604

Answers (1)

Jing Li
Jing Li

Reputation: 15116

Actually mockito is not hosted on maven.google.com.

The issue is due to two facts:

  • From mockito project repository, you can find a list of released versions, including v2.13.3
  • The library artifact is distributed at mvnrepository, and you'll see from there, not all released versions are available for downloading, for instance, 2.13.0 is listed there but not 2.13.3

Solution:

Change the dependency version to 2.13.0 instead of 2.13.3, then it works fine.

Lessons Learnt:

Always check with mvnrepository, don't trust the release page of the project.

Upvotes: 14

Related Questions