I want to include Apache HttpClient 4.1 to my project.
So, I added to my build.gradle:
dependencies {
..
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.1'
}
Running the the sanity test:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
EntityUtils.consume(null);
} catch (Exception e){
System.out.print(e.getMessage());
}
}
gives the Error:
java.lang.NoSuchMethodError: No static method consume(Lorg/apache/http/HttpEntity;)V in class Lorg/apache/http/util/EntityUtils; or its super classes (declaration of 'org.apache.http.util.EntityUtils' appears in /system/framework/org.apache.http.legacy.boot.jar)
So why is Android calling org.apache.http.legacy.boot.jar, instead of calling the added Apache HttpClient 4.1 library? And how could I force to call it?