今天从ec的工程中考过来一个post请求,但在android studio中无法正常导入以下两个包:
import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair;
Cannot resolve symbol NameValuePair
最后解决方案是:在module文件中加入了
1) android {
useLibrary 'org.apache.http.legacy'
}
2) compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
完整gradle如下:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.choe.lianlianpaydemo"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android { useLibrary 'org.apache.http.legacy'}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/securepay_stand_2.4.6.jar')
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
}