【问题标题】:How to configure IntelliJ IDEA correctly to process Android Annotations?如何正确配置 IntelliJ IDEA 以处理 Android 注释?
【发布时间】:2012-07-14 21:02:20
【问题描述】:

如何正确配置 IntelliJ IDEA 来处理注解?

使用 maven 目标 processor:process 工作正常,但如何在 IntelliJ IDEA 中不使用 maven 目标(使用它的注释处理首选项)进行处理?

在 IntelliJ 的首选项/注释处理器下,我有以下设置: 选中“Enable annotation processing”,带有选项“Obtain processors from project classpath

我将“Annotation Processors”部分留空,因为我假设它应该通过类路径自动找到。 在已处理的模块下,我选择我的 Android 模块和“target/generated-sources/apt”作为“Generated Sources Directory Name”。

在我的项目结构中,我设置了模块依赖项“Maven: com.googlecode.androidannotations:androidannotations:2.6”和“Maven: com.googlecode.androidannotations:androidannotations:api:2.6”,以便在我的类路径中拥有处理器。

但构建项目不会处理注释,而是收到警告“Annotation processing without compilation requested but no processors were found.

如果我尝试手动将注释处理器设置为“com.googlecode.androidannotations.AndroidAnnotationProcessor”并选择“/path/to/libs/androidannotations-2.6-api.jar”作为处理器的路径,我会收到错误“未找到注释处理器'com.googlecode.androidannotations.AndroidAnnotationProcessor'”尝试构建项目时。

这是我在截图中的配置:http://imageshack.us/photo/my-images/841/intellijaa.png/

【问题讨论】:

    标签: android intellij-idea android-annotations


    【解决方案1】:

    我仍然没有使用"Obtain processors from project classpath" 让它工作,但现在手动选择处理器的路径/jar 时它正在工作。

    我之前确实尝试过,但我的错误是我选择了 AA-api.jar 而不是常规的 AA.jar。

    感谢 Dave,他通过 AA google 群组的截图给出了提示:

    https://groups.google.com/forum/?fromgroups#!topic/androidannotations/PnAWuSQHkhg

    【讨论】:

    • 你知道为什么“从项目类路径获取处理器”不起作用吗?
    • 不,同时 v12 已经发布了。但是 Android 注释还有一些额外的问题。希望得到修复。但是关于您的问题:不,没有进一步研究,因为回复中提到的方法对我有用。
    猜你喜欢
    • 2015-01-29
    • 1970-01-01
    • 2017-08-24
    • 1970-01-01
    • 1970-01-01
    • 2016-05-22
    • 2020-08-05
    • 2019-01-31
    • 2017-10-26
    相关资源
    最近更新 更多