conn.addRequestProperty(entity.getContentType().getName(), entity.getContentType().getValue());
It crashes on samsung device running operating system version 4.1. While on Marshmallow Nexus 6 device, it works perfectly fine. What is the problem?
Gradle file
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
I have in my libs folder httpclient-4.3.3.jar
httpclient-cache-4.3.3.jar
httpcore-4.3.2.jar
httpmime-4.3.3.jar
Apache http client was removed since marshmallow.
See here Apache HTTP Client Removal
Solution (about embed client at all):
android {
useLibrary 'org.apache.http.legacy'
}
UPDATED:
About the particular problem see related post
Btw, in my project I can't add apache http client as a library, because of package name conflict with embed cliend. I have to use this or as described here
Please include useLibrary url like this
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
For Marshmallow Apache HTTP Client Removal
android {
useLibrary 'org.apache.http.legacy'
}
try this once
app/build/libs Files >> Project Structure >> Dependencies >> + >> File Dependencies >> and then change it to provided instead of compile (compile will cause a java exit with nonzero value 1 if you are importing too much jars.
Samsung has customised the sdk so there are channces to include more jars..