DSTU3 JSON Parser on Android

71 views
Skip to first unread message

antoa...@gmail.com

unread,
Nov 8, 2016, 2:11:25 PM11/8/16
to HAPI FHIR


Hi,
Has anyone used successfully the JSON parser with the HAPI FHIR DSTU3 libraries?

I was able to parse with the HAPI FHIR v1.6 and DSTU2.
DSTU3 has different methods and on top it looks like there are some problems with the HAPI FHIR Libraries for DSTU3.

If I try the parseResource method with DSTU3, my Android project crashes at runtime..
It crashes with different errors depending on the version of the library (v1.6 or v2).

If I use HAPI FHIR v2 then I get an error that XMLResolver class couldn't be found,
Here is a picture with a partial structure  of the v1.6 DSTU2 library which was parsing successfully.
If you look at the same structure of the v2.0  DSTU3 library, you will see that the repackage.javax is missing.



However it looks like there is still a reference to the XMLResolver class so the error message is:
 java.lang.NoClassDefFoundError: Failed resolution of: Lca/uhn/fhir/repackage/javax/xml/stream/XMLResolver;


The v1.6 DSTU3 crashes with a different error (which may apply to the v2 library too).

If you look at the structure of the v1.6 DSTU3, it contains a class called Base64BinaryType:
The Base64BinaryType imports commons codec and the commons-codec-1.10.jar is included with the HAPI FHIR for Android download.

However it turns out that Android has internal older commons codec library which makes the use of later versions of commons codec highly problematic on Android.
Here is an article on the topic:
Commons Codec on Android 

So the parser with HAPI FHIR v1.6 DSTU3 library crashes with the error:
java.lang.NoSuchMethodError: No static method decodeBase64(Ljava/lang/String;)[B in class Lorg/apache/commons/codec/binary/Base64; or its super classes (declaration of 'org.apache.commons.codec.binary.Base64' appears in /system/framework/org.apache.http.legacy.boot.jar)

Please, let me know your thoughts on this.

Thank you

   Antoaneta

.

James Agnew

unread,
Nov 8, 2016, 10:47:34 PM11/8/16
to antoa...@gmail.com, HAPI FHIR
Hi Antoaneta,

There are some issues with the Android library in HAPI FHIR 2.0 unfortunately. If you're in a position to use the 2.1-SNAPSHOT builds I'd recommend using those, otherwise I'd say just use 1.6 for now.

We'll be releasing 2.1 final this week so you won't need to wait long for a corrected build.

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+unsubscribe@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/f3fbb8a6-8440-4e64-9b1f-4a2892f0bd84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages