Can't resolve symbol 'Defaulthttpclient' and 'Httppost' in android

喜夏-厌秋 提交于 2019-12-14 04:21:16

问题


i build a new project.but i have a little problem.i can't use DefaultHttpClient and HttpPost even after i use it in my previous project already.

Is there any external librery i have to add?

i don't know how can i use both of this.

Help me for this issue.

My build.gradle

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 23
        buildToolsVersion "22.0.1"

        defaultConfig {
            applicationId "Id"
            minSdkVersion 14
            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:appcompat-v7:23.0.1'
        compile files('libs/httpcore-4.3.3.jar')
        compile files('libs/httpmime-4.3.6.jar')
    }

Thanks in advance.........


回答1:


There are two different DefaultHttpClient classes are available in the jars, you imported the wrong one,
Remove the import of DefaultHttpClient from your class file, and add this one,

import org.apache.http.impl.client.DefaultHttpClient;

One more thing, It should not be HttpPost, it will be HttpClient complete example,

import org.apache.http.impl.client.DefaultHttpClient;
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost();


来源:https://stackoverflow.com/questions/32537108/cant-resolve-symbol-defaulthttpclient-and-httppost-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!