0

I've written an annotation processor using JavaPoet library and included it as a Java Library module to my project. It compiles and works fine. The problem is - Android Studio inline compiler shows me errors that shouldn't be there.

  1. For some reason it doesn't recognize ellipsis in parameters
    first error
  2. The same as above.
    enter image description here
  3. It shows that there's no method writeTo that takes Filer type as a parameter, even though there's clearly one when you choose Go To > Declaration option. And as I mentioned - it compiles fine.
    enter image description here

I have already tried:

  1. Cleaning and rebuilding project - didn't work
  2. Syncing gradle several times - didn't work
  3. Refreshing gradle project - didn't work
  4. Using File > Invalidate Cache/Restart option - didn't work
  5. Deleting .gradle and .idea folders and syncing once again - didn't work
  6. Deleting my Java Library module from project and from disk and creating it anew with the same classes - didn't work either

Always the same three errors, so I am quite at loss here. I have to mention that this problem occurred once I downgraded JavaPoet version from 1.12.1 to 1.9.0 (Java 7 compability turned out to be crucial for my app version, so higher Java 8 versions are out of question).

My gradle file:

apply plugin: 'java-library'

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    annotationProcessor 'com.google.auto.service:auto-service:1.0-rc2'
    implementation 'com.google.auto.service:auto-service:1.0-rc2'
    implementation 'android.arch.persistence.room:runtime:1.1.1'
    implementation 'com.squareup:javapoet:1.9.0'
}

sourceCompatibility = 1.7
targetCompatibility = 1.7


It's not a deal-breaker, but it's distracting and annoying. Do you have any idea of what may be the reason for such behavior?

A. Stef
  • 23
  • 1
  • 4

1 Answers1

0

While I still don't understand what might be the reason, the errors disappeared, once I included the processor module as a project in my main app module, not as a jar.
Basically, I changed this line:

annotationProcessor files('../migrationprocessor/build/libs/migrationprocessor.jar')

To this line:

annotationProcessor project(':migrationprocessor')
A. Stef
  • 23
  • 1
  • 4