Using annotation framework in Kotlin doesn't work

question

在Kotlin中使用注解框架,发现在编译的时候注解的字段没有生效。

reason

由于Kotlin是基于jvm运行时的开发语言,所以需要单独对它引入注解环境

Solution:

这个方式是基于Gradle方式的,如使用开发工具InterJect,Android Studio,其他配置Gradle的编译环境;
只要在你使用的Kotlin的Module或者程序的build.gradle文件里加入kapt插件和相应的注解处理就好。

Steps:
1. Introduce kotlin's annotation plugin into the program or Module
Using annotation framework in Kotlin doesn't work

2. Add annotation dependency processing (the original annotationProcessor may be used, just replace it)
Using annotation framework in Kotlin doesn't work

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325130019&siteId=291194637