注解处理功能在升级到androidX后不起作用。

huangapple go评论72阅读模式
英文:

Annotation process feature not working since androidX upgrade

问题

我有一个完美运行的项目。
迁移到了androidX,之后我发现我的注解处理器不工作了。

已经完成了链接中提到的所有包更改:https://developer.android.com/jetpack/androidx/migrate,甚至使用了迁移工具。

按照这个帖子中的步骤进行操作:https://stackoverflow.com/questions/45826037/annotation-processor-not-working-no-files-are-created
将上述内容引用如下:
我尝试了常见的解决方法:

  • 从Android Studio的“最近”中移除我的项目
  • 清除缓存并重新启动Android Studio
  • 将我的项目重新导入到Android Studio中(确保在之前启用了注解处理)
  • 添加 > apply plugin: 'kotlin-android'

按照这个帖子中提到的步骤进行操作:https://stackoverflow.com/questions/56289830/enable-annotation-processing-for-existing-projects-android-studio-3-3

寻找了关于注解处理的示例,但它们都是在升级到androidX之前的:

我确实注意到注解处理器的工作方式略有不同,我正在使用"kapt project(':xx')",而不是"annotationProcessor project(path: ':xxx')"。

有什么建议吗?尽管有很多相关内容,但我觉得这个问题是有效的,因为在AndroidX和注解处理方面,除了这个问题https://stackoverflow.com/questions/52537975/migrate-annotation-processor-to-androidx,没有找到其他具体的内容。而且那个问题并没有解答我的问题,因为我已经完成了包的更改。

注解处理功能在升级到androidX后不起作用。

英文:

I have a project working perfectly.
Migrated to androidX and after that I see my annotation processor are not working.

Already done all the package changes mentioned in this link: https://developer.android.com/jetpack/androidx/migrate even used the migration tool.

Followed the steps mentioned by this guy :https://stackoverflow.com/questions/45826037/annotation-processor-not-working-no-files-are-created
Sanity checks will qoute the above:
I tried the common solutions:

  • remove my project from Android Studio recents
  • invalidate cache and restart android studio
  • import my project again into android studio (made sure that annotation processing is enabled before)
  • Added > apply plugin: 'kotlin-android'

Followed the steps this guy mentioned: https://stackoverflow.com/questions/56289830/enable-annotation-processing-for-existing-projects-android-studio-3-3

Looked for examples on annotation processing but all of them are before the androidX upgrade:

I did notice that the way annotation processors work are slightly different I am using "kapt project(':xx')" instead of "annotationProcessor project(path: ':xxx')"

Any advise I do feel this question is valid even though there are a lot of content out there cannot find anything specific to AndroidX and Annotation processor except this: https://stackoverflow.com/questions/52537975/migrate-annotation-processor-to-androidx and that does not answer the question because I already done the package changes?

注解处理功能在升级到androidX后不起作用。

答案1

得分: 0

似乎在重新执行整个过程后,我需要将Gradle升级到更高的版本,在升级Gradle到6.1.1版本后,一切都运行得很顺利。

英文:

Seems like I needed to upgrade Gradle to higher version after redoing the entire process upgraded Gradle to version 6.1.1 and worked like a charm.

huangapple
  • 本文由 发表于 2020年10月7日 17:11:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/64240874.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定