HAPI API and OKHTTP3 version issue

366 views
Skip to first unread message

Pravin Gaikwad

unread,
Jun 18, 2021, 2:22:28 PM6/18/21
to HAPI FHIR
Trying to fetch patients data using HAPI Api in Android using this code :
client!!.search<IBaseBundle>().forResource(Patient::class.java)
.where(ReferenceClientParam("organization").hasId("myOrg"))
.prettyPrint()
.returnBundle(Bundle::class.java)
.execute()

hapi fhir depencies used: 
implementation ('ca.uhn.hapi.fhir:hapi-fhir-android:5.4.0')
implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r4:5.4.0"

but it is not working with latest this dependency of okhhtp3
implementation(platform("com.squareup.okhttp3:okhttp-bom:4.9.1"))
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")

and works only with : com.squareup.okhttp3:okhttp:3.8.1

Reason is  .execute() needs Version.getUserAgent and "Version" class location has changed in latest okhttp3 version.

How to resolve this ?

Pravin Gaikwad

unread,
Jun 18, 2021, 2:39:04 PM6/18/21
to HAPI FHIR
Exact error:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.ehr.myairmed, PID: 18952
    java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/Version;
        at ca.uhn.fhir.okhttp.client.OkHttpRestfulClient.addUserAgentHeader(OkHttpRestfulClient.java:130)
        at ca.uhn.fhir.okhttp.client.OkHttpRestfulClient.addHeadersToRequest(OkHttpRestfulClient.java:123)
        at ca.uhn.fhir.okhttp.client.OkHttpRestfulClient.initBaseRequest(OkHttpRestfulClient.java:76)
        at ca.uhn.fhir.okhttp.client.OkHttpRestfulClient.createGetRequest(OkHttpRestfulClient.java:112)
        at ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation.createHttpRequest(BaseHttpClientInvocation.java:77)
        at ca.uhn.fhir.rest.client.method.HttpGetClientInvocation.asHttpRequest(HttpGetClientInvocation.java:106)
        at ca.uhn.fhir.rest.client.impl.BaseClient.invokeClient(BaseClient.java:266)
        at ca.uhn.fhir.rest.client.impl.GenericClient$BaseClientExecutable.invoke(GenericClient.java:540)
        at ca.uhn.fhir.rest.client.impl.GenericClient$FetchConformanceInternal.execute(GenericClient.java:832)
        at ca.uhn.fhir.rest.client.impl.RestfulClientFactory.validateServerBase(RestfulClientFactory.java:300)
        at ca.uhn.fhir.rest.client.impl.RestfulClientFactory.validateServerBaseIfConfiguredToDoSo(RestfulClientFactory.java:264)
        at ca.uhn.fhir.rest.client.impl.BaseClient.invokeClient(BaseClient.java:227)
        at ca.uhn.fhir.rest.client.impl.GenericClient$BaseClientExecutable.invoke(GenericClient.java:540)
        at ca.uhn.fhir.rest.client.impl.GenericClient$SearchInternal.execute(GenericClient.java:1994)
        at com.ehr.myairmed.hl7.Hl7FhirHelper$getPatientList$1.invokeSuspend(Hl7FhirHelper.kt:71)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "okhttp3.internal.Version" on path: DexPathList[[zip file "/data/app/com.ehr.myairmed-PmBruunO0gzf42vs1DzCoA==/base.apk"],nativeLibraryDirectories=[/data/app/com.ehr.myairmed-PmBruunO0gzf42vs1DzCoA==/lib/arm64, /data/app/com.ehr.myairmed-PmBruunO0gzf42vs1DzCoA==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)


James Agnew

unread,
Jun 18, 2021, 2:45:48 PM6/18/21
to Pravin Gaikwad, HAPI FHIR
Sounds like there may be a version conflict. Any patches to the hapi-fhir-android module to correct this would be welcomed.

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/6a222f06-261f-44cf-bdfb-2c107f274a4cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages