Skip to content

关于"Kotlin 调用 ArkTS 服务"时,kotlin代码如何调用生成的kotlin接口方法的问题 #41

Description

@yujingjiang14

我在KMP代码中,申明了一个"Kotlin调用ArkTS服务"的接口:CallOhosService。
Image

编译通过了,在./build/generated/ksp/ohosArm64/ohosArm64Main/kotlin/目录下生成了对应的接口函数:getCallOhosServiceApi()
Image

但是,我在commonMain的KMP代码中,调用不到这个getCallOhosServiceApi()接口函数,编译时会报错函数引用找不到。
Image

请问我应该如何处理,才能在KMP的commonMain代码中能够调用到KSP生成的getCallOhosServiceApi()接口函数。是需要我将build目录下编译生成的kotlin这些代码都手动拷贝到commonMain目录下,并且调用编译生成的Initializer.kt文件中的initialize()函数,再调用getCallOhosServiceApi()接口函数吗?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions