无法解析 android 中的符号 'Defaulthttpclient' 和 'Httppost'

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

我建一个新的project.but我有点problem.i不能用DefaultHttpClientHttpPost即使我已经在我以前的项目中使用过它。

我需要添加任何外部库吗?

我不知道如何同时使用这两个。

帮我解决这个问题。

我的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')
    }

提前致谢.........

有两种不同的 DefaultHttpClient class在 jars 中可用,你导入了错误的一个,
从您的 class 文件中删除 DefaultHttpClient 的导入,并添加这个

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

还有一点,不应该是HttpPost,应该是HttpClient 完整示例,

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