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 Classes Clash due to similar dependencies #13

Closed
wba2hi opened this issue Feb 6, 2025 · 1 comment · Fixed by #16
Closed

Duplicate Classes Clash due to similar dependencies #13

wba2hi opened this issue Feb 6, 2025 · 1 comment · Fixed by #16

Comments

@wba2hi
Copy link
Contributor

wba2hi commented Feb 6, 2025

When somebody adds the kuksa-java-sdk AND the androidx libraries to their application dependencies, they will face the following errors due to a clash of the javax:annotation-api and the org.apache.tomcat:annotations-api during the build of the application

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class javax.annotation.Generated found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)
     Duplicate class javax.annotation.PostConstruct found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)
     Duplicate class javax.annotation.PreDestroy found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)
     Duplicate class javax.annotation.Resource found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)
     Duplicate class javax.annotation.Resource$AuthenticationType found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)
     Duplicate class javax.annotation.Resources found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)
     Duplicate class javax.annotation.security.DeclareRoles found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)
     Duplicate class javax.annotation.security.DenyAll found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)
     Duplicate class javax.annotation.security.PermitAll found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)
     Duplicate class javax.annotation.security.RolesAllowed found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)
     Duplicate class javax.annotation.security.RunAs found in modules annotations-api-6.0.53.jar -> annotations-api-6.0.53 (org.apache.tomcat:annotations-api:6.0.53) and javax.annotation-api-1.3.2.jar -> javax.annotation-api-1.3.2 (javax.annotation:javax.annotation-api:1.3.2)

     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

kuksa-java-sdk embeds the org.apache.tomcat:annotations-api while the other applications mostly use the javax:annotation-api.

Right now we need to manually exclude either library e.g. by using the following snippets:

implementation("org.eclipse.kuksa:kuksa-java-sdk:0.1.1") {
    exclude("org.apache.tomcat", "annotations-api")
}

Possible solutions are:

a) exchange the org.apache.tomcat:annotations-api with javax:annotation-api (I think there were some license issues with the javax:annotations-api)

b) don’t use implementation scope but a scope (compileOnly?) which is not added as a transitive dependency for the annotations-api

c) don’t implement anything, note down what to do in the troubleshooting guide.

@wba2hi
Copy link
Contributor Author

wba2hi commented Feb 20, 2025

Closed by #16

@wba2hi wba2hi closed this as completed Feb 20, 2025
@wba2hi wba2hi linked a pull request Feb 20, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant