diff --git a/build.gradle b/build.gradle index 217f71d4b2..e30ddb1a5a 100644 --- a/build.gradle +++ b/build.gradle @@ -88,7 +88,7 @@ dependencies { compile libraries.bytebuddy, libraries.bytebuddyagent compileOnly libraries.junit4, libraries.hamcrest, libraries.opentest4j - compile libraries.objenesis + compile libraries.objenesis3 testCompile libraries.asm diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 9ae3679927..f907965b08 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -25,7 +25,9 @@ libraries.errorproneTestApi = "com.google.errorprone:error_prone_test_helpers:${ libraries.autoservice = "com.google.auto.service:auto-service:1.0-rc5" -libraries.objenesis = 'org.objenesis:objenesis:3.1' +// objenesis 3.x fails on android instrumentation test compile. https://github.com/mockito/mockito/issues/2007 +libraries.objenesis2 = 'org.objenesis:objenesis:2.6' +libraries.objenesis3 = 'org.objenesis:objenesis:3.1' libraries.asm = 'org.ow2.asm:asm:7.0' diff --git a/subprojects/android/android.gradle b/subprojects/android/android.gradle index 8f86eabb98..bd5a6959a2 100644 --- a/subprojects/android/android.gradle +++ b/subprojects/android/android.gradle @@ -3,8 +3,29 @@ description = "Mockito for Android" apply from: "$rootDir/gradle/java-library.gradle" dependencies { - compile project.rootProject + compile(project.rootProject) { + exclude group: 'org.objenesis', module: 'objenesis' + } compile libraries.bytebuddyandroid + compile(libraries.objenesis2) { + version { + strictly '[2.6, 3.0[' + } + because( + '\n' + + 'MOCKITO DEPENDENCY PROBLEM:\n' + + '\n' + + 'Mockito core uses Objenesis 3.x and Objenesis 3.x does not work with android api 25 and below.\n' + + 'If you have mockito-core dependency with mockito-android, remove mockito-core.\n' + + 'If you have mockito-kotlin, exclude mockito-core.\n' + + 'implementation("com.nhaarman.mockitokotlin2:mockito-kotlin") {\n' + + ' exclude group: "org.mockito", module: "mockito-core"\n' + + '}\n' + + 'For more information please check; \n' + + ' https://github.com/mockito/mockito/pull/2024\n' + + ' https://github.com/mockito/mockito/pull/2007\n' + ) + } } tasks.javadoc.enabled = false diff --git a/subprojects/osgi-test/osgi-test.gradle b/subprojects/osgi-test/osgi-test.gradle index 8ebcc042f3..ad5964c543 100644 --- a/subprojects/osgi-test/osgi-test.gradle +++ b/subprojects/osgi-test/osgi-test.gradle @@ -23,7 +23,7 @@ configurations { dependencies { testRuntimeBundles project.rootProject testRuntimeBundles libraries.bytebuddy - testRuntimeBundles libraries.objenesis + testRuntimeBundles libraries.objenesis3 testRuntimeBundles tasks.testBundle.outputs.files testRuntimeBundles tasks.otherBundle.outputs.files }