RESTMock
RESTMock copied to clipboard
converting android sample project to Kotlin gives ClassNotFoundException
When I convert MainActivityTest.java to kotlin, it gives below error:
$ adb shell am instrument -w -r -e notPackage org.bouncycastle.pqc.crypto.qtesla -e debug false -e class 'io.appflate.restmock.androidsample.tests.MainActivityTest' io.appflate.restmock.androidsample.test/io.appflate.restmock.androidsample.CustomTestRunner
Connected to process 8637 on device 'lge-nexus_5x-024c6d7f5e96d337'.
Started running tests
java.lang.ClassNotFoundException: io.appflate.restmock.androidsample.tests.MainActivityTest
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:400)
at androidx.test.internal.runner.TestLoader.doCreateRunner(TestLoader.java:72)
at androidx.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:104)
at androidx.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:793)
at androidx.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:547)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:390)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
Caused by: java.lang.ClassNotFoundException: Didn't find class "io.appflate.restmock.androidsample.tests.MainActivityTest" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/io.appflate.restmock.androidsample.test-1/base.apk", zip file "/data/app/io.appflate.restmock.androidsample-2/base.apk"],nativeLibraryDirectories=[/data/app/io.appflate.restmock.androidsample.test-1/lib/arm64, /data/app/io.appflate.restmock.androidsample-2/lib/arm64, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 8 more
Tests ran to completion.
And: Is this library end of life? Because we need to test co-routines but adding kotlin to the example project gives errors and it's not clear whether it is going to work.
We are gonna remove this library from our project if this is not solvable.
Hey Jim, sorry for the late answer. When it comes to kotlin support, library works perfectly fine. I've used it in dozens of kotlin projects. I wouldn't consider the library end-of-life as I'm using it on a daily basis. The plan is for the next major version to port it entirely to kotlin.
Can't really say what's the problem is based only on the stacktrace. Have you tried to run the tests from command line with ./gradlew cDAT command?
Hello, Thanks for the reply. Maybe if the example code can be updated to kotlin then it's easier.