I get IllegalArgumentException
when trying to build Apache HttpClient instance wit HttpClientBuilder:
private CloseableHttpClient delegate;
public DigestClient(String user, String pass) {
Credentials credentials = new UsernamePasswordCredentials(user, pass);
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, credentials);
delegate = HttpClientBuilder.create()
.setDefaultCredentialsProvider(credentialsProvider)
.build();
}
what I get is:
java.lang.IllegalArgumentException: Item may not be null
at org.apache.http.util.Args.notNull(Args.java:48)
at org.apache.http.config.RegistryBuilder.register(RegistryBuilder.java:58)
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:727)
at com.example.app.data.net.DigestClient.<init>(DigestClient.java:51)
Any ideas why this happens?
Here's my gradle with HttpClient's version:
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
I found a solution here:
For those who don't know Chinese:
I had to do:
and then
At least it doesn't crash this way.