【发布时间】:2018-05-30 02:23:55
【问题描述】:
我正在尝试将 PubNub jar 设置为我的 Android Studio 项目中的库。该项目是我从另一台计算机上移植过来的,所以我主要是在复制内容。
从那时到现在,我现在必须配置这个 jar 的 AnnotationProcessor,但我真的不确定这需要什么,也找不到适合我的问题的示例。
当我尝试编译我的项目时,我会收到以下消息:
Error:FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:javaPreCompileDebug'.
Annotation processors must be explicitly declared now.
The following dependencies on the compile classpath are found to contain annotation processor.
Please add them to the annotationProcessor configuration- pubnub-gson-4.19.0-all.jar (pubnub-gson-4.19.0-all.jar).
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.
Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error- message.html for more details.
我真的完全不确定这告诉我要做什么,而且我可以在互联网上找到的注释处理器示例(PubNub 没有)都指向包和类,我看不出是什么我想应该是这样的。
有人可以引导我走正确的道路吗?
对于错误的格式,我深表歉意,但该网站不允许我在块引用中提交它,因为它是“格式不正确的代码”。
【问题讨论】:
-
如果 PubNub jar 需要一些额外的配置/清单或其他任何注释内容,我将让我们的 Android 工程师对此进行审查,但错误消息确实提供了短期的替代方案:
android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true- 在我们得到明确答案之前,您可以暂时配置它吗? -
根据您的 Android 工程,请将此行添加到您的
dependencies{}块中:annotationProcessor files('libs/pubnub-gson-4.19.0-all.jar')以及implementation files('libs/pubnub-gson-4.19.0-all.jar')。让我们知道这是否可以为您解决问题,以便我们将其正式化为对这篇文章的正式答复。 -
这确实是解决方案。现在看起来很简单,但是我找不到任何资源可以建议如何解决外部 jar 库中的此类问题。我发现诸如“从 jar 中提取注释处理器并独立设置”之类的东西以及其他冗长、乏味且通常模棱两可的解决方案。
标签: java android android-gradle-plugin pubnub