15

According to the 2.4.0 update of Retrofit:

New: Converter for JAXB replaces the now-deprecated converter for Simple XML Framework.

I haven't found a single tutorial on how to implement this to replace my simple xml annotated pojos.

Can anyone share a quick guide on how to transition from simplexml to jaxb?

usernotnull
  • 3,480
  • 4
  • 25
  • 40

2 Answers2

10

I have been googling for this today, and eventually ended up on the retrofit JAXB Github page, where they politely tell us that JAXB does not work on Android:

Note that JAXB does not work on Android.

Then I found this answer, where they provide a workaround for this problem.

Please note that I have not tested this myself as I am in a similar situation as you. Trying to figure it all out when I stumbled upon your question. Hope this helps! :)

Abby
  • 1,610
  • 3
  • 19
  • 35
  • if you do work on it please update the answer accordingly to mark it as correct for others (i stayed on simplexml as i noticed how huge jaxb is when i decompiled it) – usernotnull Apr 15 '18 at 06:22
  • I work on android and in gradle I added implementation 'com.squareup.retrofit2:converter-jaxb:latest.version' – Black_Zerg Oct 30 '18 at 14:23
2

You can add like this

Add the dependency in the app-level Gradle.

implementation 'com.squareup.retrofit2:retrofit:2.7.2' (Latest version)

 Retrofit retrofit = new Retrofit.Builder()
                    .baseUrl(BuildConfig.BASE_URL)
                    .addConverterFactory(JaxbConverterFactory.create())
                    .client(httpClient.build())
                    .build();

But this will not work with your existing SimpleXmlFactory