fabric8io / mockwebserver

An extension of okhttp's mockwebserver, that provides a DSL and is easier to use
Apache License 2.0
113 stars 38 forks source link

Annotation processors must be explicitly declared now #48

Open rasmusohrstig opened 4 years ago

rasmusohrstig commented 4 years ago

I'm trying to import the library in Android studio using Gradle like so:

dependencies {
...
implementation "io.fabric8:mockwebserver:0.1.7"
}

When building the code I get the following error:

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.

I have tried this:

dependencies {
...
implementation "io.fabric8:mockwebserver:0.1.7"
annotationProcessor "io.sundr:builder-annotations:0.13.1"
annotationProcessor "io.sundr:resourcecify-annotations:0.13.1"
}

and this:

dependencies {
...
implementation "io.fabric8:mockwebserver:0.1.7"
annotationProcessor "io.sundr:builder-annotations:0.13.1"
}

but it results in duplicate imports of various classes.

The deprecated workaround android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true no longer works now.

What is the best way to import this library in Android Studio?

rasmusohrstig commented 4 years ago

I was able to solve this myself.

The problem seems to happen when you import the library in one Kotlin module and then import code from that module in another module.

The solution seems to be to import the library like this in the first module:

annotationProcessor "io.sundr:builder-annotations:0.13.1"
annotationProcessor "io.sundr:resourcecify-annotations:0.13.1"
implementation ("io.fabric8:mockwebserver:0.1.7") {
    exclude group: 'io.sundr', module: 'sundr-codegen'
}