#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

1

1

13
10mo
Solved
Join the chat
Feb 16, 2023 (10 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.

1

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

1

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3011 threads (79% resolved)

Join Our Community

Similar Threads

Resolving ClassNotFoundException in Android while using Typesense

Amal encountered a ClassNotFoundException while setting up Typesense in Android. Kishore Nallan recommended using Stack Overflow and Maven to resolve the issue. They also provided a fix for the Java client on Android, which worked for Amal.

1

21
12mo
Solved

Troubleshooting Issues with DocSearch Hits and Scraper Configuration

Rubai encountered issues with search result priorities and ellipsis. Jason helped debug the issue and suggested using different versions of typesense-docsearch.js, updating initialization parameters, and running the scraper on a Linux-based environment. The issues related to hits structure and scraper configuration were resolved.

7

131
8mo
Solved

Resolving Multilingual Search Function in Typesense Software

Bill is having difficulty with multilingual search functionality in Typesense software. Developer Kishore Nallan suggested setting a language locale and provided a demo build. The build solution had some issues, and after multiple rounds of software updates and troubleshooting, the problem still persists.

2

89
25mo

Troubleshooting Typesense Issues in Kubectl v1.26

Arnob and Rubai face issues with Typesense erasing data. Jason and Kishore Nallan suggest HA setup and persistent volume usage. Sai recommends the Typesense Kubernetes operator but Arnob experiences new errors.

1

23
4mo

Typesense Java Client Okhttp Version Conflict

Ashish faced an error with Typesense Java okhttp version. Kishore Nallan helped identify the conflict with Spring Boot version, which updated okhttp to a compatible version.

40
8mo
Solved