Closed ErrorxCode closed 2 years ago
I'm not really clear on what the issue is but it's a problem with Apache HttpClient and not with Unirest
Unirest is using deprecated Components of httpclient. It is using AllowAllHostnameVerifier
class which has been deprecated in version 4.4. You must use NoopHostnameVerifier
instead.
deprecated and gone are two different things though, the class hasn't been removed. Why are you excluding deprecated classes from your package?
Depreciation itself means that it should not be used anymore. It is causing problems in android thats why it is replaced with newer one. In android, you have to exclude Meta-INF files of library, otherwise it won't compile.
On Tue 15 Mar, 2022, 3:07 AM Ryan Bergman, @.***> wrote:
deprecated and gone are two different things though, the class hasn't been removed. Why are you excluding deprecated classes from your package?
— Reply to this email directly, view it on GitHub https://github.com/Kong/unirest-java/issues/434#issuecomment-1067320830, or unsubscribe https://github.com/notifications/unsubscribe-auth/APWEVDS6UO7NGDYMXZJX5WTU76WRJANCNFSM5QVWRNAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
what do you mean by
thats why it is replaced with newer one.
Replaced what? Apache? Did you upgrade it to 5.x? Because that won't work at all.
BTW I just checked and Unirest itself is NOT using AllowAllHostnameVerifier directly, Apache is, so again, this is more of an Apache issue https://github.com/Kong/unirest-java/search?q=AllowAllHostnameVerifier
@ErrorxCode what you are running into is that the SSLConnectionSocketFactory in Apache has a static field for a instance of AllowAllHostnameVerifier. There is no way to get around using SSLConnectionSocketFactory short of not doing TLS/SSL at all.
I know many folk using both Unirest and Apache HttpClient 4 in Android applications so I'm sure this is not a systemic problem with Android and deprecated classes.
In any case this is all internal to Apache, closing this issue as there is nothing Unirest can do. You might ask the Apache Http Client developers.
Oh you could also try using the RC of Unirest-4 because it doesn't use Apache in favor of using the Java native client
Could you please share me the link ?
On 15-Mar-2022 11:38 PM, "Ryan Bergman" @.***> wrote:
Oh you could also try using the RC of Unirest-4 because it doesn't use Apache in favor of using the Java native client
— Reply to this email directly, view it on GitHub https://github.com/Kong/unirest-java/issues/434#issuecomment-1068299689, or unsubscribe https://github.com/notifications/unsubscribe-auth/APWEVDWDA3P74L7HPOUHPXTVADG3JANCNFSM5QVWRNAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you were mentioned.Message ID: @.***>
Describe the bug Code fails for android. While compiling, we get
files found with path 'META-INF/DEPENDENCIES'
error. If we resolve this by excluding dependencies by adding packaging Block, then gets a runtime errorNoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier
To Reproduce Steps to reproduce the behavior: Just call the
as[Type]()
method and you will encounter this problem.Expected behavior A request made to the URL
Stack trace
Environmental Data:
Additional context The main problem is that while building APK, we can't include the META-INF/DEPENDENCIES'. And excluding it result in this error.