박상권의 삽질블로그

[Android ERROR&SOLVE]org.apache.http does not exist 본문

IT/Android-ERROR&SOLVE

[Android ERROR&SOLVE]org.apache.http does not exist

박상권 2015. 11. 5. 19:57

안드로이드 개발자들이 모여있는 오픈채팅방에 참여해보세요 .
Q&A 및 팁을 공유하는 방입니다..
오픈채팅방 참여



블로그를 Medium으로 옮겨서 운영하고 있습니다.
앞으로 새로운 글은 모두 미디엄 블로그를 통해서 올릴 예정입니다.
미디엄에서 다양하고 유익한 포스팅을 살펴보세요
미디엄 블로그 보기


이유

- 안드로이드 6.0 버전으로 오면서 Apache http를 지원하지 않음






https://developer.android.com/intl/ko/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client



Apache HTTP Client Removal

Android 6.0 release removes support for the Apache HTTP client. If your app is using this client and targets Android 2.3 (API level 9) or higher, use the HttpURLConnection class instead. This API is more efficient because it reduces network use through transparent compression and response caching, and minimizes power consumption. To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your build.gradle file:

android {
    useLibrary
'org.apache.http.legacy'
}









해결방법



1. /build.gradle파일에 gradle버전 업데이트


buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'

}
}









2. /app/build.gradle 파일 수정



android {
compileSdkVersion 23
buildToolsVersion '23.0.1'


// 6.0으로 바뀌면서 apache 없어짐
useLibrary 'org.apache.http.legacy'
    ...
}


Comments