Namevaluepair Error "Namevaluepair Cannot Be Resolved to a Type"

Cannot resolve symbol NameValuePair

NameValuePair is part the package org.apache which was deprecated with Android 22 and removed with Android M, which is the version against you are compiling. What is interesting is that neither the documentation of NameValuePair is reachable

NameValuePair Error NameValuePair cannot be resolved to a type

Your project's compileSdkVersion is set to 23. Apache's HttpClient library was removed from the Android SDK in API Level 23.

If you change your compileSdkVersion to 21, your app will compile cleanly. Or, there is a workaround to continue using HttpClient in Android 6.0 with Android Studio. However, for long-term development, you really need to move to something else for an HTTP API. That "something else" could be:

  • the built-in classic Java HttpUrlConnection
  • Apache's independent packaging of HttpClient for Android
  • OkHttp (my recommendation)
  • AndroidAsync

Or, depending upon the nature of your HTTP work, you might choose a library that supports higher-order operations (e.g., Retrofit for Web service APIs).

incompatible types: ArrayListBasicNameValuePair?

NameValuePair should be referring to this link. Your class, according to your link, does not extend NameValuePair. To achieve that, you need to change your code:

 public class BasicNameValuePair extends NameValuePair implements Parcelable {

and implement/override all the necessary methods as you wish/is required.

The import org.apache.http.client cannot be resolved error when I update sdk to M

For eclipse -- Find library in your sdk and add it manually
platforms/android-23/optional/org.apache.http.legacy.jar

For android studio add this line in build.gradle

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


Related Topics



Leave a reply



Submit