Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate class autoservice #171

Open
jonyChina162 opened this issue Apr 23, 2019 · 6 comments
Open

Duplicate class autoservice #171

jonyChina162 opened this issue Apr 23, 2019 · 6 comments

Comments

@jonyChina162
Copy link

I encounter this problem when run my app with dependencies hyperion:
Duplicate class com.google.auto.service.AutoService found in modules auto-service-1.0-rc2.jar (com.google.auto.service:auto-service:1.0-rc2) and classes.jar (com.willowtreeapps.hyperion:hyperion-plugin:0.9.27)

Tell the truth, it is not a good idea put a third-party class into into your libs

@ToxicBakery
Copy link
Contributor

ToxicBakery commented Apr 23, 2019

Tell the truth, it is not a good idea put a third-party class into into your libs

This isn't a very helpful comment to make and it's a generalization.

Duplicate class com.google.auto.service.AutoService found in modules auto-service-1.0-rc2.jar
(com.google.auto.service:auto-service:1.0-rc2) and classes.jar (com.willowtreeapps.hyperion:hyperion-plugin:0.9.27)

This is a bit perplexing as hyperion-plugin does not depend on auto-value. Furthermore, 0.9.27 of the Hyperion uses rc4 of auto-service, not rc2. You can verify that hyperion-plugin does not depend on auto-value here:
https://repo1.maven.org/maven2/com/willowtreeapps/hyperion/hyperion-plugin/0.9.27/hyperion-plugin-0.9.27.pom

And here is an example of a plugin which does depend on it.. or at least it should be.
https://repo1.maven.org/maven2/com/willowtreeapps/hyperion/hyperion-timber/0.9.27/hyperion-timber-0.9.27.pom

Looking at the plugin POM file and noting the dependency is missing leads me to think that the annotation processor is doing something incorrectly. It appears that the auto value dependency should be compileOnly which would correctly exclude it from the generated POM however the dependency is also clearly at least partially included in the exported JAR/AAR it seems. Either way you can use dependency exclusion to fix it on the consumer side:

https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html#sec:excluding_transitive_module_dependencies

@jonyChina162
Copy link
Author

Sorry for not describing the question clearly.
Hyperion need and should depends on auto-service, but should not directly put auto-service classes(com.google.auto.service.AutoService) in the hyperion-plugins packages like this
image
import auto-service in the build.gradle
implementation deps.auto_service
annotationProcessor deps.auto_service

Otherwise I import auto-service by myself, it will conflict and caused the question as I reported.
Now I haved imported hyperion-android source code in my app , and replace the auto-service import methods mentioned above. It works Okay.

@hbb20
Copy link

hbb20 commented Mar 8, 2021

Any update on this one? @jonyChina162 how did you solve this?

@Toubap
Copy link

Toubap commented Jul 7, 2021

facing the same issue. any update ?

@Toubap
Copy link

Toubap commented Jul 7, 2021

I'm using com.google.firebase:firebase-ml-modeldownloader-ktx which depends on auto.service then my project wont run..
I guess I have to remove hyperion for now..

@AlexKrupa
Copy link

I was blocked by this when trying to integrate Hyperion into a project with moshi-kotlin-codegen which also uses AutoService.

I figured one other, slightly dirty solution would be to use Jar Jar Links Gradle plugin to remove AutoService class from hyperion-plugin and repackage it. But it seems that the plugin doesn't work on newer (7.0+) versions of Gradle, so we're back to square one.

Is there anything blocking Hyperion from directly depending on auto-service-annotations instead of declaring the class manually?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants