Category Archives: api-23

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;

Best practice to get json from url in api 23

I'm using compileSdk 23 with support library version 23.

I've used httplegacy library ( I've copied it into app/libs folder from androidSdk/android-23/optional/org.apache.http.legacy.jar ) and in gradle I've put

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

In order to load that library.

Into my Connection class I've got a method to load an instance of DefaultHttpClient in this way:

private static HttpClient getClient(){
        HttpParams httpParameters = new BasicHttpParams();
        int timeoutConnection = 3000;
        HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
        int timeoutSocket = 3000;
        HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);

        DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);

        return httpClient;
    }

But Android Studio says me that all apache.http classes are deprecated.

What could I use in order to follow best practice?