meow
meow

Reputation: 2201

androidTestCompile mockito givning Error

I'm trying to use Mockito for instrumentation tests, when I add

androidTestCompile 'org.mockito:mockito-core:2.7.22'

I get the following error:

Error:Conflict with dependency 'org.objenesis:objenesis' in project ':app'. 
Resolved versions for app (2.1) and test app (2.5) differ. See 
http://g.co/androidstudio/app-test-app-conflict for details.

I have no clue what's wrong, I have no org.objenesis dependency specified anywhere in my code (guess it comes through mockito).

Every help, appreciated.

Upvotes: 3

Views: 779

Answers (2)

akshay_shahane
akshay_shahane

Reputation: 4643

Try this

configurations.all { resolutionStrategy { force 'org.objenesis:objenesis:2.1' } }

or

Just exclude it in your main project. exclude group: 'org.objenesis'

Upvotes: 7

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364604

The link in the exception tells you how to remedy this.

configurations.all {
  resolutionStrategy {
    force 'org.objenesis:objenesis:2.1.0'
  }
}

Otherwise you can use:

androidTestCompile 'org.objenesis:objenesis:2.1.0'

Upvotes: 1

Related Questions