adyen-java-api-library icon indicating copy to clipboard operation
adyen-java-api-library copied to clipboard

Android support below Android 8

Open jnischler opened this issue 1 year ago • 7 comments

Hey,

we are using your library in one of our payment applications. As we need local communication with your terminals, we need to use this library or at least the models locally.

In the past you made several changes preventing us from using newer versions of your library, as the used functions are not available on android.

So far, we identified at least two problems. The Jackson version is too high. See issue: https://github.com/FasterXML/jackson-databind/issues/3658 2.14+ is no longer supported by Android Versions below 8. We tried the library with an older Jackson version, and everything works just fine. See: https://github.com/FasterXML/jackson-databind?tab=readme-ov-file#compatibility

As we have a lot of payment devices with android 7 we need to use at max Jackson 2.13.X.

Using gradle “resolutionStrategy.force” we can force the Jackson version to an older version.

We also identified another problem caused by the base64 functions used.

A wile ago you replaced the apache base64 library with java.utils.Base64. https://github.com/Adyen/adyen-java-api-library/commit/891748f221506e296b3fbcd426a4afb517d887b2 java.utils.Base64 is only available from API Level 26+ (Android 8)

I fully understand that using older Version of a library might not be that modern but it also breaks support for older devices. Especially payment devices trend to not feature the latest android versions and therefore a lot of devices are still using Android 7 or even Android 5.

Just have a look at your own devices https://docs.adyen.com/point-of-sale/android-terminals/.

What is the recommended way to go?

Thanks and best regards Julian

jnischler avatar Apr 26 '24 11:04 jnischler

Hi @jnischler,

Thanks for reaching out to us with this issue. We were not aware of these version issues with Android, but I fully agree with you that it would make sense to be compatible with our own devices and their respective android versions. I created an internal ticket to review our dependencies and see whether we are able to downgrade some of them. We will keep you posted!

Best, Jilling Adyen

jillingk avatar Apr 29 '24 10:04 jillingk

Hi @jillingk.

Thanks for the update, In the prerequisites you also mention Java 11. https://github.com/Adyen/adyen-java-api-library?tab=readme-ov-file#prerequisites

Android does support Java 11 features through desugaring but only a subset: https://developer.android.com/studio/write/java11-default-support-table

As of now we only noticed the 2 already mentioned problems.

As an alternative to Jackson you could have a look at google gson: https://github.com/google/gson

Or if you would like to boost performance then you could consider dsl-json: https://github.com/ngs-doo/dsl-json

Another idea would be to consider creating a plain Kotlin library. With Kotlin "kotlinx.serialization".

If we can help in any way, feel free to reach out.

Regards Julian

jnischler avatar Apr 30 '24 15:04 jnischler

Hi @jnischler,

Actually even though we mention java 11 on the readme, technically the library is still compatible with java 8 so that you don't have that to worry about!

As for the serialization library, we actually specifically migrated away from GSON to Jackson as this was in our opinion the industry standard (by a small margin). What I would like to do however is see if I can downgrade our jackson dependencies so we're compatible with older android versions. We will try to pick this up asap.

Kotlin library we've been thinking about for a while now. I will poke around and see if this is something we can build, however don't hold any hope as we might have other priorities for now :)

I'll come back to you once I've managed to downgrade above mentioned dependencies!

Best, Jilling Adyen

jillingk avatar May 03 '24 07:05 jillingk

Hi Jilling,

Of course I understand just wanted to give you some hints :)

We did test the library with an older Version of Jackson and everything worked for us. But we didn't to a lot of testing. We are using: 2.13.5

Regards Julian

jnischler avatar May 03 '24 13:05 jnischler

Struggeling with the same issue.

Managed to bypass the Jackson issue by excluding Jackson dependency from adyen-java-api lib, and including a version lower than 2.14 in app build file.

However, the missing java.util.Base64 is still unsolved.

Hoping for a fix soon.

Edit: using Adyen S1E devices, running Android 7.

runemart avatar May 24 '24 07:05 runemart

Struggeling with the same issue.

Managed to bypass the Jackson issue by excluding Jackson dependency from adyen-java-api lib, and including a version lower than 2.14 in app build file.

However, the missing java.util.Base64 is still unsolved.

Hoping for a fix soon.

Edit: using Adyen S1E devices, running Android 7.

to force gradle to always use a specific version of jackson we use this snipet:

resolutionStrategy.force(
		// jackson version 2.14+ Android SDK 26+ as we need to target lower SDK versions
		// we need to prevent libs to increase the jackson version
		// for example adyen did increase the jackson version and this caused a failure on some devices
		// see https://github.com/FasterXML/jackson-databind?tab=readme-ov-file#jdk
		"com.fasterxml.jackson.core:jackson-core:$jacksonVersion",
		"com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion",
		"com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
		"com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion",
		"com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion"
	)

jnischler avatar May 29 '24 20:05 jnischler

Hey @DjoykeAbyah , @jillingk.

Sorry for bother you again. But we would really need to know if you are working on a fix for this issue or if we need to find a workaround on our side.

Thanks, you very much. Beste regards Julian

jnischler avatar Jun 14 '24 12:06 jnischler

Hi @DjoykeAbyah @jillingk, do you have any update on this topic? Thanks and best, Max

maxmauthner avatar Aug 09 '24 12:08 maxmauthner

Hi @maxmauthner,

Thank you for your patience, and I apologize for the delay in getting back to you. We're currently investigating the issue to ensure we make the most sustainable choice. I'll keep you updated with any progress.

Kind regards,

Djoyke Adyen

DjoykeAbyah avatar Aug 23 '24 07:08 DjoykeAbyah

Hi @maxmauthner, @jnischler, and @runemart,

We've downgraded the Jackson dependencies to ensure compatibility with Android 7. Regarding the java.util.Base64 import, we're currently exploring a sustainable solution to add support for Android 7.

We'll keep you updated!

Best regards,

Djoyke Adyen

DjoykeAbyah avatar Aug 23 '24 14:08 DjoykeAbyah

Hi @maxmauthner, @jnischler and @runemart,

I wanted to let you know we've just downgraded the dependency for Base64. link to pr!

Kind regards,

Djoyke Adyen

DjoykeAbyah avatar Aug 30 '24 08:08 DjoykeAbyah

Hi, @DjoykeAbyah this issue hasn't been fixed in v28.3.0 on Android. I get this build error.

Failed to transform jackson-core-2.17.2.jar (com.fasterxml.jackson.core:jackson-core:2.17.2) to match attributes {artifactType=enumerated-runtime-classes, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-runtime}.

I tried to force jackson's version which I am using in the project (2.13.1), but unsuccessfully. It looks that version of jackson has been downgraded to Android's compatible Java version, but there is revert of this downgrade, too. I don't know if this change was intentional or a mistake, but anyway, please help me, because I need to build up your library.

grossrichard avatar Sep 04 '24 12:09 grossrichard

Hi @grossrichard,

Sorry I see indeed we forgot to update both our Jackson dependencies. I've just now updated them both correctly and triggered our release so you should be able to check this works in release v28.3.1.

Please keep us posted as to whether this works for you!

Best, Jilling Adyen

jillingk avatar Sep 04 '24 12:09 jillingk

sorry for the delay. Yes your changes worked thanks. We are now using the latest version.

Thanks

jnischler avatar Oct 03 '24 10:10 jnischler

Hi @DjoykeAbyah, I got to test version 28.5.1 today, and it appears java.util.Base64 is used in ByteArrayToBase64TypeAdapter.java also, which causes crash (NoClassDefFoundError) on Android 7. I found other references to import java.util.Base64 also, but not sure how they impact apps.

at com.adyen.terminal.serialization.ByteArrayToBase64TypeAdapter.serialize(ByteArrayToBase64TypeAdapter.java:40)
at com.adyen.terminal.serialization.ByteArrayToBase64TypeAdapter.serialize(ByteArrayToBase64TypeAdapter.java:34)
at com.google.gson.internal.bind.TreeTypeAdapter.write(TreeTypeAdapter.java:108)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:73)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$2.write(ReflectiveTypeAdapterFactory.java:247)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:490)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:73)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$2.write(ReflectiveTypeAdapterFactory.java:247)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:490)
at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:73)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$2.write(ReflectiveTypeAdapterFactory.java:247)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:490)
at com.google.gson.Gson.toJson(Gson.java:944)
at com.google.gson.Gson.toJson(Gson.java:899)
at com.google.gson.Gson.toJson(Gson.java:848)
at com.google.gson.Gson.toJson(Gson.java:825)
at com.adyen.service.TerminalLocalAPI.request(TerminalLocalAPI.java:65)
at no.wtw.paymentterminal.adyen.DoDiagnostics.doDiagnostics(DoDiagnostics.java:41)
at no.wtw.paymentterminal.AdyenPaymentTerminal.init(AdyenPaymentTerminal.java:129)
at com.linefare.inspector.android.data.repository.PaymentTerminalRepositoryImpl$initialize$4.invokeSuspend(PaymentTerminalRepositoryImpl.kt:94)
...

runemart avatar Oct 17 '24 09:10 runemart

Hi @runemart,

Thanks for bringing this to our attention, I see we missed a couple references to java.util. I'm removing them in #1376.

Best, Jilling Adyen

jillingk avatar Oct 17 '24 10:10 jillingk