clojure-clutch / clutch

A Clojure library for Apache CouchDB.
Other
225 stars 37 forks source link

Base64 Android worries #54

Closed dehubbed closed 12 years ago

dehubbed commented 12 years ago

The new dependency on apache commons codec 1.6 won't work on Android b/c Android contains an undocumented older version of apache commons codec, probably version 1.3. (WTF!!) This older version doesn't have the Base64.encodeBase64String method.

What will happen is that the internal version of the Base64 class will be loaded as a priority over the 1.6 version included by Clutch when the Base64 class is referenced, and then Clojure will look for the encodeBase64String and can't find it. You could possibly get away with including commons codec 1.3 in Clutch, or include 1.6 but only use 1.3 methods, but the whole thing is messy. Would be nice to have a Clojure 1.2 compatible data.codec or what to keep things clean.

Also the clutch HTTP stuff still references sun.misc.Base64 but I guess that will go away as part of moving to clj_http.

cemerick commented 12 years ago

The remaining sun.misc usage for the HTTP authentication was an oversight. Fix pushed, and a new 0.3.1-SNAPSHOT is now in clojars.

This android Base64 encoding problem is apparently not new, and well-known: http://stackoverflow.com/questions/2047706

However, clj-http — which depends upon Apache's HTTPClient — uses commons-codec, and so I suspect won't work on Android either.

Android is clearly in the wrong here, and giving up HTTPClient (probably the best Java HTTP client available AFAICT?) is too high a price for Android compatibility. Surely Android will fix this at some point (simply shading their rev of commons-codec would be appropriate); maybe it already is fixed in some newer revs? Filing a bug with them would be a good idea if not.

dehubbed commented 12 years ago

Ah yes I had seen the stackoverflow issue, should have pointed to it.

The wrongful inclusion of commons codec is still there as of the most recent Android 4.0.3. Will raise an issue there.

No need to give up Apache HTTPClient as it is in fact the official included default and recommended HTTP client for Android. Stock clj_http therefore works well on Android but gives some warnings b/c of double inclusion of Apache HTTP. I have used clj_http on Android before, possibly without Base64 relevant functions though (attachments, authentication).

I will investigate this further and comment here as I go.