typesense / typesense-java

Java client for Typesense
https://typesense.org/docs/latest/api/
Apache License 2.0
60 stars 29 forks source link

Can't create a connection #23

Closed amalshiwantha closed 1 year ago

amalshiwantha commented 2 years ago

Description

When i going to create a connection using configuration typesense getting an error as "NoClassDefFoundError"

Error Log

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/osgi/framework/SynchronousBundleListener; at org.glassfish.jersey.internal.ServiceFinder.find(ServiceFinder.java:265) at org.glassfish.jersey.client.ClientConfig$State.<init>(ClientConfig.java:143) at org.glassfish.jersey.client.ClientConfig.<init>(ClientConfig.java:509) at org.typesense.api.ApiCall.<init>(ApiCall.java:53) at org.typesense.api.Client.<init>(Client.java:27)

Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@89a43a1, Dispatchers.Main.immediate] Caused by: java.lang.ClassNotFoundException: Didn't find class "org.osgi.framework.SynchronousBundleListener" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.soho.sohoapp.dev-m0tbsgxUsxKfxfIyGwYvPw==/base.apk"],nativeLibraryDirectories=[/data/app/com.soho.sohoapp.dev-m0tbsgxUsxKfxfIyGwYvPw==/lib/arm64, /data/app/com.soho.sohoapp.dev-m0tbsgxUsxKfxfIyGwYvPw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]

Metadata

Jar File - implementation files('libs/typesense-java-0.0.3.jar') Run On - Android 12

kishorenc commented 1 year ago

I've fixed the issues that you noticed with the Java client on Android. I was able to also test it on a sample Android application.

You can try with this version:

0.0.7-beta1

If you run into any duplicate class issue in Android studio, please add the following to the build file:

configurations {
    cleanedAnnotations
    implementation.exclude group: 'org.jetbrains' , module:'annotations'
    implementation.exclude group: 'org.jetbrains.kotlin' , module:'kotlin-stdlib'
}
kishorenc commented 1 year ago

Android compatibility has been tested and fixed in 0.0.10 that has been published now.