[英]Java AnnotationProcessor can not generate code with gradle 5.1.1
I write an annotation processor following this blog , the code has no problem, but it just can not generate the file, then I found out is the Gradle version. 我在此博客之后编写了一个注释处理器,代码没有问题,但是它无法生成文件,所以我发现是Gradle版本。
my Gradle setting : 我的Gradle设置:
root -> build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
}
gradle/wrapper/gradle-wrapper.properties: gradle产出/包装/ gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
So, when I downgrade the Gradle version to 4.6, everything is fine. 因此,当我将Gradle版本降级到4.6时,一切都很好。
my changed Gradle setting: 我更改的Gradle设置:
root -> build.gradle
: root -> build.gradle
:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
gradle/wrapper/gradle-wrapper.properties: gradle产出/包装/ gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
I looked up the doc about Gradle 5.x, got nothing. 我查阅了有关Gradle 5.x的文档,一无所获。 Is there some changed behavior can cause this problem?
是否有某些行为改变会导致此问题?
What should I do when I want to use Gradle 5.x? 我想使用Gradle 5.x怎么办?
I had this same problem on upgrade of Android Studio (3.3 -> 3.4) (This upgrades gradle from 4.10.1 -> 5.1.1). 我在升级Android Studio(3.3-> 3.4)时遇到了同样的问题(此升级是从4.10.1-> 5.1.1升级的)。 Not 4.6 exactly but I noticed no breaking change from 4.6 -> 4.10 so I assume the following will work.
并非完全是4.6,但我注意到从4.6-> 4.10以来没有重大变化,因此我认为以下内容将起作用。 I'm using kapt, and an annotation processor I built as a java module.
我正在使用kapt,以及我作为Java模块构建的注释处理器。 Everything worked fine before the update.
在更新之前,一切正常。
My solution was: 我的解决方案是:
- Upgrade com.google.auto.service:auto-service
to 1.0-rc6
-将
com.google.auto.service:auto-service
升级到1.0-rc6
- Add annotationProcessor "com.google.auto.service:auto-service:1.0-rc6"
to the annotation processor's build.gradle file. -将注解处理器
annotationProcessor "com.google.auto.service:auto-service:1.0-rc6"
到注解处理器的build.gradle文件中。
Found my answer via these: 通过这些找到了我的答案:
- https://github.com/gradle/gradle/issues/7941 -https://github.com/gradle/gradle/issues/7941
- https://github.com/ishaigor/annotation-processor-sample/commit/d7645914b9f53a5f350c7098973f3554c48e75d8 -https://github.com/ishaigor/annotation-processor-sample/commit/d7645914b9f53a5f350c7098973f3554c48e75d8
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.