Android Studio (Gradle) cannot find Mockito

后端 未结 4 1627
余生分开走
余生分开走 2020-12-11 16:39

I try to use Mockito from within Android Studio 1.2.2 but I get the following error:

Error:(50, 17) Failed to resolve: org.mockito:mockito-core:1.10.1

4条回答
  •  隐瞒了意图╮
    2020-12-11 16:51

    I was stuck into a similar problem, and adding the mockito jar file manually did the thing for me.

    To do that, first create a directory called "libs" in your app directory. Take note that this directory should be in the same level as that of the src/main and build directories. Next, download the mockito jar file and paste it into the libs directory.

    Include that into your dependencies in the app level build.gradle file:

    dependencies {
        compile files('libs/add-your-jar-file-name-here')
    }
    

    Sync the gradle and that should do the job.

    Refer to this answer for more detailed answer with snapshots.

提交回复
热议问题