的Apache HTTP进口不工作 [英] apache http imports not working

查看:187
本文介绍了的Apache HTTP进口不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用useLibraryorg.apache.http.legacy在我的build.gradle,但部分进口不工作

下面是我的进口:

 进口org.apache.http.HttpEntity; //工作
进口org.apache.http.Htt presponse; //工作
进口org.apache.http.client.ClientProtocolException; //不工作
进口org.apache.http.client.methods.HttpPost; //不工作
进口org.apache.http.impl.client.DefaultHttpClient; //不工作
进口org.apache.http.params.BasicHttpParams; //工作

下面是我的build.gradle

 应用插件:'com.android.application安卓{
  compileSdkVersion 23
  buildToolsVersion23.0.2  useLibraryorg.apache.http.legacydefaultConfig {
    的applicationIDcom.user.app
    15的minSdkVersion
    targetSdkVersion 23
    版本code 1
    的versionName1.0
}buildTypes {
    发布 {
        minifyEnabled假
        proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
     }
   }
 }依赖{
  编译文件树(导演:'库',包括:['的* .jar'])
  编译com.android.support:appcompat-v7:23.1.0
  编译org.apache.httpcomponents:的HttpCore:4.4.3
}


解决方案

尝试 org.apache.http.legacy.jar 添加到您的libs文件夹。

您可以找到这个jar在的Andr​​oid / SDK /平台/ Android的23 /可选

这行添加到您的 app.gradle 文件

 编译文件树(导演:'库',包括:['的* .jar'])

和删除 useLibrary'org.apache.http.legacy

利用图书馆没有任何问题,这样林

I am using useLibrary 'org.apache.http.legacy' in my build.gradle but some imports are not working

Here are my imports:

import org.apache.http.HttpEntity; // Working
import org.apache.http.HttpResponse; // Working
import org.apache.http.client.ClientProtocolException; // Not Working
import org.apache.http.client.methods.HttpPost; // Not Working
import org.apache.http.impl.client.DefaultHttpClient; // Not Working
import org.apache.http.params.BasicHttpParams; // Working

Here is my build.gradle

apply plugin: 'com.android.application'

android {
  compileSdkVersion 23
  buildToolsVersion "23.0.2"

  useLibrary 'org.apache.http.legacy'

defaultConfig {
    applicationId "com.user.app"
    minSdkVersion 15
    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.1.0'
  compile 'org.apache.httpcomponents:httpcore:4.4.3'
}

解决方案

Try to add org.apache.http.legacy.jar to your libs folder.

You can find this jar in Android/Sdk/platforms/android-23/optional

Add this line to your app.gradle file

compile fileTree(dir: 'libs', include: ['*.jar'])

And delete useLibrary 'org.apache.http.legacy'

This way Im using library without any problem

这篇关于的Apache HTTP进口不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆