Home > Mobile >  Java. Lang. NoSuchFieldError: No field, the INSTANCE of the type Lorg/apache/HTTP/conn/SSL/
Java. Lang. NoSuchFieldError: No field, the INSTANCE of the type Lorg/apache/HTTP/conn/SSL/

Time:02-04

In the Android project compile error:
Process: com. Discovery. Ocrserver, PID: 9769
Java. Lang. NoSuchFieldError: No field, the INSTANCE of the type Lorg/apache/HTTP/conn/SSL/AllowAllHostnameVerifier; In class, Lorg/apache/HTTP/conn/SSL/AllowAllHostnameVerifier; Or its superclasses (declaration of 'org. Apache. HTTP. Conn. SSL. AllowAllHostnameVerifier' appears in/system/framework/framework. The jar: classes2. Dex)
The at org. Apache. HTTP. Conn. SSL. SSLConnectionSocketFactory. & lt; clinit> (SSLConnectionSocketFactory. Java: 144)






Said the class AllowAllHostnameVerifier no INSTANCE
But I introduce jars: httpclient - 4.5.2 AllowAllHostnameVerifier inside there is a INSTANCE;

Finally found to be due to I call AllowAllHostnameVerifier when the class is invoked automatically Android API26 of AllowAllHostnameVerifier,

This is how to return a responsibility? Why jars and the inside of the API have just call the inside of the API? What would need to change?

Thank you for the great god

CodePudding user response:

In the app build. Gradle add

Android {
.

UseLibrary 'org. Apache. HTTP. Legacy'
}

CodePudding user response:

reference 1st floor u010531038 response:
in app build. Gradle add

Android {
.

UseLibrary 'org. Apache. HTTP. Legacy'
}


However, and no... Still prefer using framwork. The inside of the jar class don't know how to solve

CodePudding user response:

To describe the problem:
Use httpclient library in a class in the android framework. Also exists in the jar, and using the framework. The first class in the jar caused problems

I use a third-party OCR library, the library using the httpclient - 4.5.2. Org in the jar/apache/HTTP/conn/SSL/AllowAllHostnameVerifier classes, but this class exists in the android framework, so runtime operation framework of AllowAllHostnameVerifier first class, but the framework of AllowAllHostnameVerifier classes and httpclient - 4.5.2. AllowAllHostnameVerifier class content there are differences in the jar, therefore, to the following error:

Java. Lang. NoSuchFieldError: No static field, the INSTANCE of the type Lorg/apache/HTTP/conn/SSL/AllowAllHostnameVerifier; In class, Lorg/apache/HTTP/conn/SSL/AllowAllHostnameVerifier; Or its superclasses (declaration of 'org. Apache. HTTP. Conn. SSL. AllowAllHostnameVerifier' appears in/system/framework/framework. The jar: classes2. Dex)

Problem is, I can't change I use third-party OCR library code, so to meet like this must use httpclient - 4.5.2. A method of a class in the jar, but this class in the framework, but the relevant methods used have no, you is how to solve? Thank you

CodePudding user response:

The building Lord, this how do you solve

CodePudding user response:

Apache HTTP framework has been Google abandoned, why still dying, rather than a one-time change okhttp, province of trouble in the future,
No this question should be, can't rewrite this right,

CodePudding user response:

reference 5 floor qq_30837593 reply:
the building Lord, this how do you solve it

For okhttp is the way

CodePudding user response:

Meet the same problem, the inside of the run time priority loaded the fw class, please the main problem is how to solve?
  • Related