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.

my Gradle setting :

root -> build.gradle:

dependencies {
    classpath 'com.android.tools.build:gradle:3.4.2'
}

gradle/wrapper/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.

my changed Gradle setting:

root -> build.gradle:

dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
}

gradle/wrapper/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. Is there some changed behavior can cause this problem?

What should I do when I want to use Gradle 5.x?

1 Answer 1

3

I had this same problem on upgrade of Android Studio (3.3 -> 3.4) (This upgrades gradle from 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. I'm using kapt, and an annotation processor I built as a java module. Everything worked fine before the update.

My solution was:
- Upgrade com.google.auto.service:auto-service to 1.0-rc6
- Add annotationProcessor "com.google.auto.service:auto-service:1.0-rc6" to the annotation processor's build.gradle file.

Found my answer via these:
- https://github.com/gradle/gradle/issues/7941
- https://github.com/ishaigor/annotation-processor-sample/commit/d7645914b9f53a5f350c7098973f3554c48e75d8

Hope this helps.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks. implementation 'com.google.auto.service:auto-service:1.0-rc5' add this line to processor's gradle file : annotationProcessor 'com.google.auto.service:auto-service:1.0-rc5' it works!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.