NoSuchMethodError:没有静态方法beforeCheckcastToFunctionOfArity

时间:2017-08-22 12:22:00

标签: java android mockito kotlin

我使用JavaJUnit4Mockito对我的Android应用进行了测试,使用Espresso编写。 我试图将它们转换为Kotlin,但我的测试失败了,这个例外:

java.lang.NoSuchMethodError: No static method beforeCheckcastToFunctionOfArity(Ljava/lang/Object;I)Ljava/lang/Object; in class Lkotlin/jvm/internal/TypeIntrinsics; or its super classes (declaration of 'kotlin.jvm.internal.TypeIntrinsics' appears in /data/app/com.takhfifan.takhfifan-2/base.apk)
at com.takhfifan.takhfifan.activity.AddressSelectActivityTest$configApiToReturnAddresses$1.answer(AddressSelectActivityTest.kt:131)

stacktrace引用的行是此代码的第二行(转换):

doAnswer { invocation ->
        val resultListener = invocation.arguments[1] as (List<Address>)->Unit
        runLater(after) { resultListener(Arrays.asList<Address>(*addresses)) }
        null
    }.`when`<Api>(api).listCustomerAddresses(any(), any(), any())

我在上面嘲笑的函数的声明是这样的:

open fun listCustomerAddresses(sessionId: String,resultListener: (List<Address>)->Unit, errorListener: (Throwable)->Unit) {...

我尝试将其添加到我的proguard文件中,但没有任何改变:

-keep class kotlin.jvm.internal.TypeIntrinsics {
    public static Object beforeCheckcastToFunctionOfArity(***);
}

0 个答案:

没有答案