Android studio 中NameValuePair跟BasicNameValuePair 不能正常导包问题
Android studio 中NameValuePair跟BasicNameValuePair 不能正常导包问题
针对一个post请求,android studio中无法正常导入以下两个包:
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
Cannot resolve symbol NameValuePair
最后解决方案是:
在module文件中加入了
android {
...
useLibrary 'org.apache.http.legacy'
dependencies {
...
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
}
}
到此问题得到解决,如果还是报错出现如下:
compile 'org.apache.httpcomponents:httpclient:4.5.5'
出现红色报错线并提示下列错误:
httpclient defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. less... (Ctrl+F1)
There are a number of libraries that duplicate not just functionality of the Android platform but using the exact same class names as the ones provided in Android -- for example the apache http classes. This can lead to unexpected crashes. To solve this, you need to either find a newer version of the library which no longer has this problem, or to repackage the library (and all of its dependencies) using something like the jarjar tool, or finally, rewriting the code to use different APIs (for example, for http code, consider using HttpUrlConnection or a library like okhttp). Issue id: DuplicatePlatformClasses
解决办法:
在android中添加下列代码:
configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
}
}
截图如下:

重新点击出错语句编译即可解决。
Android studio 中NameValuePair跟BasicNameValuePair 不能正常导包问题的更多相关文章
- Android Studio中导入v4,v7和recyclerview-v7包的方法
概述 Android Studio中新建工程中会默认导入v7的包,即在gradle中默认配置了com.android.support:appcompat-v7:x.x.x的依赖.但是不会默认为我们配置 ...
- Android开发的小技巧,在Android Studio中使用Designtime Layout Attributes
在编写xml文件时,为了预览效果,经常会使用默认填上一些内容,比如TextView时,随便写上一个text <TextView ... android:text="Name:" ...
- android studio 中移除module和恢复module
一.移除Android Studio中module 在Android Studio中想要删除某个module时,在Android Studio中选中module,右键发现没有delete,如图: An ...
- Android Studio中Button等控件的Text中字符串默认大写的解决方法
初学Android的时候,在Android Studio中xml里面添加一个Button.EditText等控件后,它的Text总是会显示大写,即使你输入的字符串是小写也不行,控制字符串大小写的属性是 ...
- .Net程序员之不学Java做安卓开发:Android Studio中的即时调试窗口
对学.Net的人来说,JAVA开发是一场噩梦. .net中的即时窗口,调试时直接在里面写代码,对程序中的各种方法/属性进行调用,很方便. Android Studio中找了好久,参考如下网址,也有类似 ...
- 如何将Eclipse中的项目迁移到Android Studio 中
如何将Eclipse中的项目迁移到Android Studio 中 如果你之前有用Eclipse做过安卓开发,现在想要把Eclipse中的项目导入到Android Studio的环境中,那么首先要做的 ...
- 在android studio 中使用applicationid的问题
现在我需要对项目app的某个功能做性能测试,主要测试耗电量的多少. 1.我想到的方式是,我需要在同一台手机测试,同一个应用,需要安装在手机两次,第二次安装不覆盖第一次的安装. 在android stu ...
- Android studio 中的配置编译错误总结
1.编译Andorid 工程的时候,有时候出现gradle 报下面的错误. Error:(1, 0) Cause: com/android/build/gradle/LibraryPlugin : U ...
- Android Studio中清单文件改versionCode和versionName没效果的原因
在Android Studio中,项目的versionCode 和versionName 的控制不是在AndroidManifest.xml清单文件中更改的,而是在项目的build.gradle中更改 ...
随机推荐
- 使用Retrofit2调用HTTP API
前言 Retrofit会将你的HTTP接口调用转换为java的interface,你不必去实现这个接口,交给Retrofit来创建动态代理. 首先,贴上官网和Javadoc. 官网上的例子 加依赖,下 ...
- 【原创】获取MySQL crash 时的core file
最近有台服务器的MySQL经常crash,为了进一步定位问题,开启了mysql core file功能,开启步骤如下,供参考 [开启步骤] 1. my.cnf文件中增加2个配置选项 [mysqld] ...
- [python]源码-对象的创建和行为
(明天论文就要送审了!!!距离毕业一个月!!!) 现在还记得刚开始学python时候被这种动态语言惊到的那种感觉,列表和字典对象可以随意伸缩,简直不能更帅了,但是一直不知道内部到底是怎么实现的,pyt ...
- [HDU6155]Subsequence Count(线段树+矩阵)
DP式很容易得到,发现是线性递推形式,于是可以矩阵加速.又由于是区间形式,所以用线段树维护. https://www.cnblogs.com/Miracevin/p/9124511.html 关键在于 ...
- 写在OI退役后和高中毕业前的一些话
更新日志: 2017.02.13 开坑 2017.02.13 更新[零][壹] 2017.02.14 更新[贰] 2017.02.26 更新[叁][肆] 2017.03.04 锅多如狗,停更一周 20 ...
- 2018-2019-2 20162318《网络对抗技术》Exp4 恶意代码分析
一.实验目标 监控你自己系统的运行状态,看有没有可疑的程序在运行. 分析一个恶意软件,就分析Exp2或Exp3中生成后门软件:分析工具尽量使用原生指令或sysinternals,systracer套件 ...
- 文件上传demo
前端代码: <form action="upload.php" enctype="multipart/form-data" method="po ...
- 使用matplotlib的示例:调整字体-设置colormap和colorbar
使用matplotlib的示例:调整字体-设置colormap和colorbar # -*- coding: utf-8 -*- #********************************** ...
- php输出mysqli查询出来的结果
php连接mysql我有文章已经写过了,这篇文章主要是介绍从mysql中查询出结果之后怎么输出的问题. 一:mysqli_fetch_row(); 查询结果:array([0]=>小王) 查询: ...
- 最快的BT软件rtorrent Step by Step指南
原文地址:http://forum.ubuntu.org.cn/viewtopic.php?t=165069 rtorrent是linux下最快的bt下载软件,由于支持DHT网络,可以很好的于迅雷和B ...