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 manuallyplatforms/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
Upload File with PHP and Save Path to SQL
Google Calendar API Batch Request PHP
Insert Multiple Data into Database in Yii 2
Laravel Get Route Name from Given Url
Dompdf - Attach Created PDF to Email
Phpunit: Doing Assertions on Non-Public Variables
Apostrophes Are Breaking My MySQL Query in PHP
Issues Porting PHP/Gd Wrapper to Imagick
Unable to Scrape Content from a Website
What Is Laravel Render() Method For
PHP Foreach() with Arrays Within Arrays
Creating a Secure File Hosting Server for PDFs
Strip_Tags() Function Blacklist Rather Than Whitelist
How to Dynamically Set Table Name in Eloquent Model
File Upload PHP $_Files Undefined Index Error