Android instrumentation test packaging fails for mockito-android 3.5.0 with minSdk < 26
See original GitHub issueWe’ve upgraded from mockito-android:3.4.6
to mockito-android:3.5.0
. I’m attempting to package up my instrumented tests by running the assembleAndroidTest
gradle task. The task fails with the following errors:
/Users/<me>/.gradle/caches/transforms-2/files-2.1/fb7959dc5bfc8ebb26ad0660efa1929e/jetified-mockito-core-3.5.0.jar: D8: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
/Users/<me>/.gradle/caches/transforms-2/files-2.1/4d4498fa5552ba637b5a9594a0871b80/jetified-objenesis-3.1.jar: D8: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
/Users/<me>/.gradle/caches/transforms-2/files-2.1/4d4498fa5552ba637b5a9594a0871b80/jetified-objenesis-3.1.jar: D8: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
and with root cause:
com.android.tools.r8.utils.b: Error: /Users/<me>/.gradle/caches/transforms-2/files-2.1/4d4498fa5552ba637b5a9594a0871b80/jetified-objenesis-3.1.jar:org/objenesis/instantiator/util/DefineClassHelper$Java8.class, java.lang.Class org.objenesis.instantiator.util.DefineClassHelper$Java8.defineClass(java.lang.String, byte[], int, int, java.lang.Class, java.lang.ClassLoader, java.security.ProtectionDomain), MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)
at com.android.tools.r8.utils.y0.a(:21)
at com.android.tools.r8.utils.O.a(:51)
... 35 more
Issue Analytics
- State:
- Created 3 years ago
- Reactions:21
- Comments:54 (23 by maintainers)
Top Results From Across the Web
Android instrumentation test failed due to mockito
It is my decision for mocking @RunWith(AndroidJUnit4::class) class DashboardFragmentTest : KoinTest { @Rule @JvmField val activityRule ...
Read more >Test - Android Developers
Fix ActivityScenario's issue with starting an Activity from intent with package name in self-instrumenting tests. Reduce ActivityScenario overhead by using ...
Read more >Min-Api 26 - ADocLib
Ask questionsAndroid instrumentation test packaging fails for mockitoandroid 3.5.0 with minSdk < 26. We've upgraded from mockitoandroid:3.4.6 to.
Read more >Instrumented test run fails with 'Installation ... - Issue Tracker
When running an instrumentation test against a simple app, the app fails to install to the target device. 1) Right click 'androidTest' folder...
Read more >Mockito 3.5.0 API - javadoc.io
0.1 Mockito Android support 0.2 Configuration-free inline mock making 1. Let's verify some behaviour! 2. How about some stubbing? 3. Argument matchers
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@TimvdLippe there is a handier workaround for objenesis 3.x, without excluding it from
mockito-core
. In rootbuild.gradle
we can add:Here’s the stacktrace that I get when using 3.5.7: