Reputation: 3356
Since Apache's HTTP library has been deprecated in favor of HttpURLConnection, i have been trying to add the legacy library to my project. I added the line
useLibrary 'org.apache.http.legacy'
to build.gradle but the the HTTP methods cannot be resolved still. How do i get this to work?
These are the errors i am getting;
Error:(21, 59) error: cannot find symbol class List
Error:(21, 64) error: cannot find symbol class NameValuePair
Error:(23, 13) error: cannot find symbol class DefaultHttpClient
Error:(23, 48) error: cannot find symbol class DefaultHttpClient
Error:(24, 13) error: cannot find symbol class HttpEntity
Error:(25, 13) error: cannot find symbol class HttpResponse
Error:(28, 17) error: cannot find symbol class HttpPost
Error:(28, 41) error: cannot find symbol class HttpPost
Error:(30, 44) error: cannot find symbol class UrlEncodedFormEntity
Error:(37, 42) error: cannot find symbol variable URLEncodedUtils
Error:(40, 17) error: cannot find symbol class HttpGet
Error:(40, 39) error: cannot find symbol class HttpGet
Error:(48, 28) error: cannot find symbol variable EntityUtils`
The following is my build.gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.19.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.radioafrica.music"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:palette-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.0@aar') {
transitive = true;
}
compile('com.twitter.sdk.android:twitter:1.6.1@aar') {
transitive = true;
}
compile 'com.nineoldandroids:library:2.4.0'
}
Upvotes: 4
Views: 5645
Reputation: 8211
After some research, I have found that the library is actually included upon compile and packaging, but not shown in IDE.
As a workaround, you can remove the line
useLibrary 'org.apache.http.legacy'
copy the file org.apache.http.legacy.jar from Android/Sdk/platforms/android-23/optional
to libs
folder in your project.
Reference on people reporting this problem
https://code.google.com/p/android/issues/detail?id=181474
https://code.google.com/p/android/issues/detail?id=183668
Upvotes: 6