-
Notifications
You must be signed in to change notification settings - Fork 57
Description
First off, I want to thank the maintainers of this repo for doing the herculean work of getting JUnit 5 up and running on Android!
I'm running into an issue where I can run my instrumentation tests just fine within Android Studio, but if I try to run them from the command line I get two sets of errors.
First off, these are the errors I'm seeing:
First error:
module.myModule.myAndroidTest > initializationError[emulator-5554 - 8.1.0] FAILED
java.lang.NoSuchMethodError: No static method newKeySet()Lj$/util/concurrent/ConcurrentHashMap$KeySetView; in class Lj$/util/concurrent/ConcurrentHashMap; or its super classes (declaration of 'j$.util.concurrent.ConcurrentHashMap' appears in /data/app/module.ins.test-TnAh7dSYSDIdYT5oUAsyiQ==/base.apk!classes6.dex)
at org.junit.platform.commons.logging.LoggerFactory.<clinit>(LoggerFactory.java:36)
Second error:
module.myModule.myPackage.myOtherAndroidTest > initializationError[emulator-5554 - 8.1.0] FAILED
java.lang.IllegalStateException: junit-platform-runner not found on runtime classpath of instrumentation tests; please review your androidTest dependencies or raise an issue.
at de.mannodermaus.junit5.AndroidJUnit5Builder.runnerForClass(RunnerBuilder.kt:72)
The second error is repeated for each class in my androidTest folder.
Here's the build.gradle for the module I'm attempting to test:
apply plugin: 'com.android.library'
apply plugin: "de.mannodermaus.android-junit5"
android {
compileSdkVersion ...
defaultConfig {
...
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArgument "runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder"
}
...
compileOptions {
coreLibraryDesugaringEnabled=true
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
packagingOptions {
exclude "META-INF/LICENSE*"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
...
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10'
testImplementation "junit:junit:${rootProject.ext.junitVer}"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.6.2"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:5.6.2"
androidTestImplementation "androidx.test:runner:1.3.0"
androidTestImplementation "org.junit.jupiter:junit-jupiter-api:5.6.2"
androidTestImplementation "de.mannodermaus.junit5:android-test-core:1.2.0"
androidTestRuntimeOnly "de.mannodermaus.junit5:android-test-runner:1.2.0"
androidTestImplementation "org.mockito:mockito-core:3.3.3"
testImplementation "org.mockito:mockito-core:3.3.3"
}
...The errors I'm seeing are awfully close to the errors in this stack overflow post, but we're not using Kotlin so the proposed solution doesn't work for us (unless the issue is some library we're using is using Kotlin under the hood?)
Any help anyone could be provide would be much appreciated. Thank you!
EDIT: Tried to add Kotlin to the project so I could specify the jvmTarget in the kotlinOptions block and add a dependency on the jdk8 standard library as outlined in the linked StackOverflow post but alas no luck.
EDIT: It looks like updating the minSdk to >= 24 fixes the issue.