包含http-4.2.1 Android应用程序(Include Http-4.2.1 with A

2019-07-31 04:45发布

我想包括最新版本的HTTP与我的Android应用程序,这是4.2.1。 现在想从Apache下载网站库并将它包含libs文件夹中,然后到我的应用程序的构建路径。

在包括HTTP - 4.2.1,我得到了在logcat的输出如下

08-28 02:42:40.917: D/dalvikvm(25641): DexOpt: 'Lorg/apache/http/client/ResponseHandler;' has an earlier definition; blocking out
08-28 02:42:40.917: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/Decoder;' has an earlier definition; blocking out
08-28 02:42:40.927: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/BinaryDecoder;' has an earlier definition; blocking out
08-28 02:42:40.927: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/Encoder;' has an earlier definition; blocking out
08-28 02:42:40.927: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/BinaryEncoder;' has an earlier definition; blocking out
08-28 02:42:40.927: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/DecoderException;' has an earlier definition; blocking out
08-28 02:42:40.927: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/EncoderException;' has an earlier definition; blocking out
08-28 02:42:40.927: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/StringDecoder;' has an earlier definition; blocking out
08-28 02:42:40.927: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/StringEncoder;' has an earlier definition; blocking out
08-28 02:42:40.927: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/StringEncoderComparator;' has an earlier definition; blocking out
08-28 02:42:40.937: D/dalvikvm(25641): DexOpt: 'Lorg/apache/commons/codec/binary/Base64;' has an earlier definition; blocking out
08-28 02:42:42.847: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HeaderElement;': multiple definitions
08-28 02:42:42.847: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HeaderElementIterator;': multiple definitions
08-28 02:42:42.847: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HeaderIterator;': multiple definitions
08-28 02:42:42.847: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpConnection;': multiple definitions
08-28 02:42:42.847: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpClientConnection;': multiple definitions
08-28 02:42:42.847: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpConnectionMetrics;': multiple definitions
08-28 02:42:42.847: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpEntity;': multiple definitions
08-28 02:42:42.857: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpMessage;': multiple definitions
08-28 02:42:42.857: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpRequest;': multiple definitions
08-28 02:42:42.857: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpEntityEnclosingRequest;': multiple definitions
08-28 02:42:42.857: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpException;': multiple definitions
08-28 02:42:42.857: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpHost;': multiple definitions
08-28 02:42:42.857: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpInetConnection;': multiple definitions
08-28 02:42:42.857: D/dalvikvm(25641): DexOpt: not verifying 'Lorg/apache/http/HttpRequestFactory;': multiple definitions

我的问题是我能做到这一点? 这是否会创建与SDK一起HTTP库已经纳入版本有些冲突?

Answer 1:

不幸的是这个问题没有一个优雅整洁的解决方案。 你唯一的选择是将所有的HttpClient类移动到一个自定义命名空间(“org.apache.http” - >“my.http”)使用maven灯罩的插件或者利用现有的库的预包装叉这里

编辑

截至今天人们还可以使用官方的Apache的HttpClient 4.3的谷歌Android端口 。



Answer 2:

<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK">
<accessrules>
<accessrule kind="nonaccessible" pattern="org/apache/http/**"/>
</accessrules>
</classpathentry>

我修复它修改应用程序的.classpath文件这样的,我是找到开源项目开放gpstracker解决方案



文章来源: Include Http-4.2.1 with Android App