`NoClassDefFoundError` It looks like I’m missing a...
# spek
r
NoClassDefFoundError
It looks like I’m missing a dependency or something?
r
yeah, most likely. Can you share your build file?
r
Thanks for taking a look. I’m at my wit’s end trying to puzzle this out
r
Can you try dowgrading to JUnit 5.1.1?
spek-runner-junit5
may not be compatible with 5.3.1. Also, any reason you are still using
2.0.0-rc.1
?
r
I just hadn’t updated the dependency yet to
2.0.0
, I fixed it. I dropped JUnit down to
5.1.1
to no avail. I’m getting the same error
My sample test is located in
/src/test/java
and I’m using just a dummy test until I get up and running.
Copy code
object ASpec : Spek({
    Feature("A feature") {
        Scenario("A Scenario") {
            var avar = 1
            When("A When") {
                avar += 1
            }

            Then("A Then") {
                assertEquals(2, avar)
            }
        }
    }
})
r
Weird, can you follow the setup here? https://spekframework.org/setup-android/
r
My setup is exactly what is represented on that page, just in kotlin instead of groovy. Also, without the jacoco setup (is that required?)
r
or rather remove dependency declarations for JUnit 5?
r
Removed. I’m still seeing the same error
r
Hmm, can you run
./gradlew dependencies
on your project and paste the output here?
r
Super weird response from that
Copy code
------------------------------------------------------------
Root project
------------------------------------------------------------

No configurations
r
you need to run it in the android app project not root.
./gradlew <app>:dependencies
r
oh, duh, thanks
wow… it’s really really big
like.. more than 512kb
r
just pipe the out to a file then send it here 🙂
also what version of
de.mannodermaus.android-junit5
are you using? From what I remember it uses a specific version of junit5 (which is configurable)
r
de.mannodermaus.gradle.plugins:android-junit5:1.3.2.0
output.txt
r
what's this warning:
AGBPI: {"kind": "warning","text":"The kotlin-android plugin is currently applied after android-junit5! To guarantee full compatibility, please declare it above the JUnit 5 plugin."}
?
r
no idea..
r
and weird, I can't see any dependencies to JUnit 5 in the output.
r
Copy code
id("com.android.application")
    id("jacoco")
    id("de.mannodermaus.android-junit5")
    kotlin("android.extensions")
    kotlin("android")
    kotlin("kapt")
    id("realm-android")
    id("com.google.gms.google-services")
}
r
can you move id("de.mannodermaus.android-junit5") as the last entry?
r
Yeah, I moved it down, building now
Still getting the same error
maybe there’s something wrong with my test configuration?
when I run
./gradlew test
from command line, the build is successful, but I don’t see any test results
r
probably, can you clone https://github.com/spekframework/spek/tree/2.x/samples/android then apply your changes in such a way that it replicates your issue?
I can take a look once I have that.
r
yep, will do
Looks like the android junit5 version is lower than mine, gonna give that a shot
looks like
de.mannodermaus.gradle.plugins:android-junit5:1.2.0.0
is incompatible with kotlin build scripts
ok, so I added
Copy code
testInstrumentationRunnerArguments["runnerBuilder"] = "de.mannodermaus.junit5.AndroidJUnit5Builder"
to the default config and I’m not getting the error anymore, it’s just not able to find any tests
So, that’s definitely a step in the right direction
there must be something wrong with the test configuration at this point
Thanks for all your help @raniejade
r
nw! If you need more help just let me know.