commercetools / commercetools-sdk-java-v2

The e-commerce SDK from commercetools for Java.
https://commercetools.github.io/commercetools-sdk-java-v2/javadoc/index.html
Apache License 2.0
34 stars 15 forks source link

Android SDK #155

Open ilians opened 3 years ago

ilians commented 3 years ago

The website currently states the Java SDK is currently not available due to the Java 8 dependency. This now no longer seems to be true due to the Java 8 desugaring support

The current SDK seems to work correctly with Android though (using SDK 26+)

References: https://developer.android.com/studio/write/java8-support https://docs.commercetools.com/sdk/jvm-sdk#about-the-java-sdk

It might be helpful to add some integration docs though for Android defining the ProGuard / R8 rules required to run the project plus the minimum required Android version (and other helpful info?).

Having a dedicated Android SDK as some point in the future like Swift / iOS has would be even better as that could take care of stuff like storing the access token(s) on device for a persistent sessions or handing of anonymous sessions which now seems to be something that has to be configured manually.

jenschude commented 3 years ago

The docs description seems to be still mixing up some things between the v1 and v2 version. The Java SDK should be fine to be used with Android.

jenschude commented 3 years ago

Also this hackathon demo is outdated now and may not be able to be compiled anymore it shows that the v2 could be used with Android https://github.com/katmatt/summerhack-2019

ilians commented 3 years ago

Whoops, I accidentally already posted the question when still writing.. sorry about that. I've managed to get the Java SDK 2 working as well which is what caused me to post the enhancement here so that others may try and use it as well.

It might be helpful to add some integration docs though for Android defining the ProGuard / R8 rules required to run the project plus the minimum required Android version (and other helpful info?).

Having a dedicated Android SDK as some point in the future like Swift / iOS has would be even better as that could take care of stuff like storing the access token(s) on device for a persistent sessions or handing of anonymous sessions which now seems to be something that has to be configured manually.

vaso92 commented 4 months ago

Any update on proguard rules for android? Has anyone actually managed to use the sdk in android? I am getting errors:

Missing class javax.security.auth.login.AppConfigurationEntry$LoginModuleControlFlag (referenced from: javax.security.auth.login.AppConfigurationEntry[] org.asynchttpclient.spnego.SpnegoEngine$1.getAppConfigurationEntry(java.lang.String))
Missing class javax.security.auth.login.AppConfigurationEntry (referenced from: javax.security.auth.login.AppConfigurationEntry[] org.asynchttpclient.spnego.SpnegoEngine$1.getAppConfigurationEntry(java.lang.String))
Missing class org.osgi.framework.Bundle (referenced from: java.lang.Object org.javamoney.moneta.OSGIServiceHelper$JDKUtilServiceFactory.getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration) and 7 other contexts)
Missing class org.osgi.framework.BundleActivator (referenced from: org.javamoney.moneta.internal.OSGIActivator)
Missing class org.osgi.framework.BundleContext (referenced from: org.osgi.framework.BundleContext org.javamoney.moneta.internal.OSGIServiceProvider.bundleContext and 10 other contexts)
Missing class org.osgi.framework.InvalidSyntaxException (referenced from: java.util.List org.javamoney.moneta.internal.OSGIServiceProvider.getServices(java.lang.Class))
Missing class org.osgi.framework.ServiceFactory (referenced from: org.javamoney.moneta.OSGIServiceHelper$JDKUtilServiceFactory)
Missing class org.osgi.framework.ServiceReference (referenced from: void org.javamoney.moneta.OSGIServiceHelper.unregisterService(org.osgi.framework.Bundle, java.lang.Class, java.lang.Class) and 5 other contexts)
Missing class org.osgi.framework.ServiceRegistration (referenced from: java.lang.Object org.javamoney.moneta.OSGIServiceHelper$JDKUtilServiceFactory.getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration) and 2 other contexts)
Missing class org.osgi.framework.Version (referenced from: void org.javamoney.moneta.OSGIServiceHelper.registerService(org.osgi.framework.Bundle, java.lang.Class, java.lang.Class))
jenschude commented 4 months ago

No we didn't tested it yet and it's not planned at the moment.

The errors reported coming from the AsyncHttpClient. You may want to use commercetools-okhttpl-client4 instead as OkHttp already publishes proguard rules.

The other errors are coming from java money and moneta. You may have to try to keep the OSGI, javax and org.javamoney classes.

Another option would be for testing purposes to disable the minify process as it had been done in the hackathon app: https://github.com/katmatt/summerhack-2019/blob/master/app/build.gradle#L23