4

I created a new android project with the following gradle file:

android {
   ...
   dexOptions {
        javaMaxHeapSize "4g"
    }
   ...
}

dependencies {
   ...
    compile 'com.linkedin.dexmaker:dexmaker-mockito:2.16.0'
   ...
}

But when I build my app I get:

Conflict with dependency 'com.android.support:multidex' in project ':app'. Resolved versions for app (1.0.3) and test app (1.0.1) differ. See http://g.co/androidstudio/app-test-app-conflict for details.

How can I solve this issue?

AmiNadimi
  • 5,129
  • 3
  • 39
  • 55
Insoft
  • 548
  • 6
  • 21

2 Answers2

6

The error says you are using 2 versions of com.android.support:multidex.Check this https://stackoverflow.com/a/37357786/3111083 So in your case it should be

android {
    configurations.all {
        resolutionStrategy.force 'com.android.support:multidex:1.0.3'
    }
}

After changing this Clean and rebuild.

Sunil Sunny
  • 3,949
  • 4
  • 23
  • 53
  • i understand this resolves the issue, but could you explain where is it using multidex version 1.0.1 so that i can update that also? – madroid Jul 30 '18 at 06:21
  • @madroid It might be using in any 3rd party libraries you are using. Like in the op's case the multidex was 1.0.1 in mockito. – Sunil Sunny Jul 30 '18 at 09:13
  • ok thanks for the response, i actually ended up keeping version of multidex to 1.0.1 as it was pretty much stable and it got the work done – madroid Jul 30 '18 at 10:08
0

Mockito depends only on a specific version, so the dependency conflict should be on your side. Do you have any dependencies that depend on specific version? i.e.in your build.gradle file. If so, you can try using a ResolutionStrategy to force 1.0.3 on them.

AmiNadimi
  • 5,129
  • 3
  • 39
  • 55