代码之家  ›  专栏  ›  技术社区  ›  RadekJ

从其他模块调用重写的挂起函数时出现kotlin、coroutines、NoSuchMethodError

  •  3
  • RadekJ  · 技术社区  · 8 年前

    NoSuchMethodError (详见下文)。

    我现在做的就是:

    应用程序 解放党 .

    解放党 这里我有一个接口( OtherModuleInterface )用挂起法( test

    应用程序 OtherModuleImpl )这个界面的一部分。

    如果我这样称呼它:

     val myOtherModuleObject : OtherModuleImpl = OtherModuleImpl()
        runBlocking { myOtherModuleObject.test() }
    

    那么它工作得很好。

    其他模块接口 作为值的类型:

    val myOtherModuleObject : OtherModuleInterface = OtherModuleImpl()
    runBlocking { myOtherModuleObject.test() }
    

    java.lang.NoSuchMethodError:com.example.lib.OtherModuleInterface.test(Lkotlin/coroutines/experimental/Continuation;)Ljava/lang/Object .

    val mySameModuleObject : SameModuleInterface = SameModuleImpl()
        runBlocking { mySameModuleObject.test() }
    

    您可以在此处签出代码以查看整个项目配置: https://github.com/rjuszczyk/kotlin-coroutines-problem 跑 ExampleUnitTest

    0 回复  |  直到 8 年前