Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling Google Download Library targing API 23 Android Marshmallow

I'm using Google's Download library for expansion pack downloading as distributed through the 'Android SDK' manager. Building using Eclipse/Ant since haven't migrated to AS/Gradle yet - but any solution would help.

In API 23 Apache HTTP goes away. And I already implemented a workaround to get Google's LVL to compile. (Lvl library and android marshmallow)

But the download library is substantially larger beast to tackle and not sure I really want to fix Google's code - probably just write my own instead if necessary.

Does anyone know of a convenient "drop in" (-ish) replacement library or suitable workaround?

~~

Compile errors for unavailable imports in 'com.google.android.vending.expansion.downloader.impl.AndroidHttpClient'

import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.HttpRequestInterceptor; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.ResponseHandler; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.params.HttpClientParams; import org.apache.http.client.protocol.ClientContext; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.scheme.PlainSocketFactory; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.scheme.SocketFactory; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.entity.AbstractHttpEntity; import org.apache.http.entity.ByteArrayEntity; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.RequestWrapper; import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; import org.apache.http.params.BasicHttpParams; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; import org.apache.http.params.HttpProtocolParams; import org.apache.http.protocol.BasicHttpContext; import org.apache.http.protocol.BasicHttpProcessor; import org.apache.http.protocol.HttpContext;

like image 275
DevByStarlight Avatar asked Oct 18 '22 23:10

DevByStarlight


1 Answers

Okay, a bit of github searching and found a solution. Ironically, it's mentioned in stackoverflow too - I just didn't use right keywords in my search I suppose. So if you happen to arrive here, then bounce on over to SMarek's question/answer/solution and give +1 the answer. Solution: (http://stackoverflow.com/q/32178854/735533) Library: (https://github.com/smarek/httpclient-android)

Edit:

NOTE: As of Oct 26, 2015, SMarek's library above doesn't quite build successfully as-is

Meanwhile, it turns out there is an "easier" drop-in solution for Ant users in lieu of the "usesLibrary org.apache.http.legacy" option for gradle users.

  • Copy SDK/platforms/android-23/optional/org.apache.http.legacy.jar into application's ./libs directory
  • (and add jar to build path classpath, etc)
  • Then add the following to proguard

    -keep class org.apache.http.** { *; }
    -dontwarn org.apache.http.**
    -dontwarn android.net.**

NOTE: The android.net 'dontwarn' will mask OpenSSL calls ("android.net.http.SslCertificate"). In my case it arises from WebKit which I'm not using (although 3rd party libs might)

Unfortunately, it pushed my app over the 65k limit. Never a dull moment.

like image 179
DevByStarlight Avatar answered Oct 30 '22 12:10

DevByStarlight