【问题标题】:import org.apache.http components cannot be resolvedimport org.apache.http 组件无法解析
【发布时间】:2016-02-17 08:36:50
【问题描述】:

我的 org.apache.http 组件有问题。我正在创建一个注册页面并导入 ff:

  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.NameValuePair;
  import org.apache.http.client.ClientProtocolException;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.entity.UrlEncodedFormEntity;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.message.BasicNameValuePair;

我也把我的 build.gradle 改成了这个

 android {

compileSdkVersion 23
buildToolsVersion "23.0.0"
useLibrary 'org.apache.http.legacy'

还有这个:
依赖{ 类路径'com.android.tools.build:gradle:1.3.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

但我仍然收到错误。我了解到 API23 不再支持 HttpClient。有什么办法可以创建我的注册。请帮助我:) 谢谢!

【问题讨论】:

    标签: android-studio androidhttpclient


    【解决方案1】:

    试试这个

      compileSdkVersion 23
    buildToolsVersion '19.1.0'
    useLibrary 'org.apache.http.legacy'
    

    使用构建工具 19.1.0 可以让我正常工作,但是当您打开文件时会报告错误,但您应该能够构建您的项目

    【讨论】:

    • 如果我将 buildtoolsversion 从 23 降级到 19,会影响我的设计吗?
    • nope ..design 是由 api 级别而不是构建版本
    • 我已经将我的 buildtoolsversion 更改为 19.1.0 但我仍然收到错误。
    【解决方案2】:

    我希望这能像对我一样帮助别人。 此问题的最新解决方案是添加:

    implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    

    在你的 gradle 依赖项中:

    build.gradle > dependencies {
        ...
        implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    }
    

    清理项目,重建,全部完成。

    【讨论】:

      猜你喜欢
      • 2012-08-13
      • 2015-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-17
      • 2017-08-11
      相关资源
      最近更新 更多