#community-help

Resolving Duplicate Classes Error with Typesense and Kotlin

TLDR Matt faced "Duplicate class" errors in a Kotlin Android app after adding Typesense dependency. Kishore Nallan suggested excluding conflicting groups which resolved the issue.

Powered by Struct AI
+11
white_check_mark1
13
7mo
Solved
Join the chat
Feb 16, 2023 (7 months ago)
Matt
Photo of md5-18043fa2013a4a35d5157a653a6a4de9
Matt
08:13 AM
Hello everyone 👋, I want to try out Typesense in an Android app written in Kotlin.
To start with, I created a sample project. After adding the Typesense dependency implementation 'org.typesense:typesense-java:0.0.8' I get Duplicate class found error, build output:

Duplicate class com.fasterxml.jackson.annotation.JacksonAnnotation found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JacksonAnnotationValue found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JacksonAnnotationsInside found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JacksonInject found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JacksonInject$Value found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonAlias found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonAnyGetter found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonAnySetter found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonAutoDetect found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonAutoDetect$1 found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonAutoDetect$Value found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonAutoDetect$Visibility found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonBackReference found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonClassDescription found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonCreator found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonCreator$Mode found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonEnumDefaultValue found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonFilter found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonFormat found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonFormat$Feature found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonFormat$Features found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonFormat$Shape found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonFormat$Value found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonGetter found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonIdentityInfo found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonIdentityReference found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonIgnore found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonIgnoreProperties found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonIgnoreProperties$Value found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonIgnoreType found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonInclude found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonInclude$Include found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonInclude$Value found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonIncludeProperties found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonIncludeProperties$Value found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonKey found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonManagedReference found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonMerge found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonProperty found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonProperty$Access found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonPropertyDescription found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonPropertyOrder found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonRawValue found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonRootName found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonSetter found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonSetter$Value found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonSubTypes found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonSubTypes$Type found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 (org.typesense:typesense-java:0.0.8)
Duplicate class com.fasterxml.jackson.annotation.JsonTypeId found in modules jackson-annotations-2.14.1 (com.fasterxml.jackson.core:jackson-annotations:2.14.1) and typesense-java-0.0.8 

(...)

Is there any recommended way to deal with this?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:15 AM
Is this a brand new android sample project?
Matt
Photo of md5-18043fa2013a4a35d5157a653a6a4de9
Matt
08:19 AM
Yes, I just created a new project based on an android template.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:22 AM
Can you try adding this to the build file?

configurations {
    cleanedAnnotations
    implementation.exclude group: 'org.jetbrains' , module:'annotations'
    implementation.exclude group: 'org.jetbrains.kotlin' , module:'kotlin-stdlib'
}
Matt
Photo of md5-18043fa2013a4a35d5157a653a6a4de9
Matt
08:36 AM
This is helpfull (less error lines in output) but error still exist.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:38 AM
I think if you exclude other groups in a similar way it will work. When I tested this on a sample project last month, it worked.
+11
Matt
Photo of md5-18043fa2013a4a35d5157a653a6a4de9
Matt
08:40 AM
Yes, this seems like a good way to deal with it. Will test it. Thank you for help.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
08:42 AM
If it does not work, please post the sample project on GitHub and I can try
Matt
Photo of md5-18043fa2013a4a35d5157a653a6a4de9
Matt
08:44 AM
Ok, I'll let you know the result
09:36
Matt
09:36 AM
I did as you said and the app works. Final configuration:

minSdkVersion = 26```
configurations {
cleanedAnnotations
implementation.exclude group: 'org.jetbrains' , module:'annotations'
implementation.exclude group: 'org.jetbrains.kotlin' , module:'kotlin-stdlib'
implementation.exclude group: 'org.apache.logging.log4j' , module:'log4j-api'
implementation.exclude group: 'org.apache.logging.log4j' , module:'log4j-core'
implementation.exclude group: 'com.squareup.okio' , module:'okio'
implementation.exclude group: 'com.squareup.okhttp3' , module:'okhttp'
implementation.exclude group: 'jakarta.xml.bind' , module:'jakarta.xml.bind-api'
implementation.exclude group: 'javax.xml.bind' , module:'jaxb-api'
implementation.exclude group: 'jakarta.activation' , module:'jakarta.activation-api'
implementation.exclude group: 'io.swagger.core.v3' , module:'swagger-annotations'
implementation.exclude group: 'com.fasterxml.jackson.module' , module:'jackson-module-jaxb-annotations'
}```
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:41 AM
Good to know. Do you have some of these dependencies on your sample project?
Matt
Photo of md5-18043fa2013a4a35d5157a653a6a4de9
Matt
09:50 AM
No, I only added dependency for Typesense:
dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'

    //Typesense client
    implementation 'org.typesense:typesense-java:0.0.8'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}

Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
09:52 AM
Thanks I'll check
white_check_mark1