Exception in Apatche Http library

Denis Radist July 31, 2017

Hello everyone,

 

I have faced with the issue on Android using Jira-Rest-Client:

FATAL EXCEPTION: main
Process: com.example.redra.newtoggletimer, PID: 18803
java.lang.NoSuchFieldError: No field INSTANCE of type Lorg/apache/http/message/BasicLineFormatter; in class Lorg/apache/http/message/BasicLineFormatter; 
or its superclasses (declaration of 'org.apache.http.message.BasicLineFormatter' appears in /system/framework/org.apache.http.legacy.boot.jar)
                                        at org.apache.http.impl.nio.codecs.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52)
                                        at org.apache.http.impl.nio.codecs.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56)
                                        at org.apache.http.impl.nio.codecs.DefaultHttpRequestWriterFactory.<clinit>(DefaultHttpRequestWriterFactory.java:46)
                                        at org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory.<init>(ManagedNHttpClientConnectionFactory.java:75)
                                        at org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory.<init>(ManagedNHttpClientConnectionFactory.java:83)
                                        at org.apache.http.impl.nio.conn.ManagedNHttpClientConnectionFactory.<clinit>(ManagedNHttpClientConnectionFactory.java:64)
                                        at com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient.<init>(ApacheAsyncHttpClient.java:175)
                                        at com.atlassian.httpclient.apache.httpcomponents.ApacheAsyncHttpClient.<init>(ApacheAsyncHttpClient.java:123)
                                        at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory.doCreate(DefaultHttpClientFactory.java:68)
                                        at com.atlassian.httpclient.apache.httpcomponents.DefaultHttpClientFactory.create(DefaultHttpClientFactory.java:35)
                                        at com.atlassian.jira.rest.client.internal.async.AsynchronousHttpClientFactory.createClient(AsynchronousHttpClientFactory.java:63)
                                        at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.create(AsynchronousJiraRestClientFactory.java:35)
 at com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory.createWithBasicHttpAuthentication(AsynchronousJiraRestClientFactory.java:42)
                                        at com.example.redra.newtoggletimer.MainActivity$1$1.onFinish(MainActivity.java:48)
                                        at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:127)
                                        at android.os.Handler.dispatchMessage(Handler.java:105)
                                        at android.os.Looper.loop(Looper.java:156)
                                        at android.app.ActivityThread.main(ActivityThread.java:6577)
                                        at java.lang.reflect.Method.invoke(Native Method)
                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)

 

After this I have found several solutions on StackOverflow:

useLibrary 'org.apache.http.legacy'

or

compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'

but niether helped me

I am testing my App on Android 7
Does anyone know what changes ? Why have I got such exception ?

My Gradle file is the following:

apply plugin: 'com.android.application'

android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.smartway.butler.timebutler"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
packagingOptions {
pickFirst 'META-INF/license.txt'
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/jersey-module-version'
exclude 'org/apache/http/nio/client/version.properties'
exclude 'org/apache/http/version.properties'
exclude 'org/apache/http/nio/version.properties'
exclude 'org/apache/http/entity/mime/version.properties'
}
dexOptions {
preDexLibraries = false
additionalParameters=['--core-library']
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.atlassian.fugue:fugue:2.6.1'
compile 'com.atlassian.jira:jira-rest-java-client-core:4.0.0'
compile 'com.atlassian.jira:jira-rest-java-client-api:4.0.0'
compile 'org.slf4j:slf4j-simple:1.6.4'
compile 'commons-logging:commons-logging:1.2'
compile 'commons-net:commons-net:3.6'
// compile 'org.apache.httpcomponents:httpmime:4.3.6'
//compile 'org.apache.httpcomponents:httpcore:4.4.5'
// compile('org.apache.httpcomponents:httpmime:4.3.6') {
// exclude module: 'httpclient'
// }
//
// compile('org.apache.httpcomponents:httpmime:4.3.6') {
// exclude module: 'httpclient'
// }
// compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
// compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
//compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
//compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
// compile('org.apache.httpcomponents:httpmime:4.3.6') {
// exclude module: 'httpclient'
// }
// compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
testCompile 'junit:junit:4.12'
}

I am so tired ... Nothing working from solutions around the internet ...

 

0 answers

Suggest an answer

Log in or Sign up to answer