Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 975
Jing Li Avatar asked Dec 02 '25 09:12

Jing Li


1 Answers

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.

like image 190
Jing Li Avatar answered Dec 05 '25 08:12

Jing Li



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!