我用的android studio,添加HttpClient的依赖包之后没有报错,但是编译不通过
首先声明,我使用的是android studio ,SDK用的是最近的23版本。
1、因为4.0之后已经没有了HttpClient,我添加了compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'依赖,但是还是找不到HttpClient的包!!这一步有错么?
2、然后我又百度加上自己不断换包五六次尝试,添加如下依赖compile 'org.apache.httpcomponents:httpclient-osgi:4.5.1'这个包,能够使用HttpClient了。但是令人崩溃的是居然HttpResponse又用不了,不知道是哪个包的问题。于是又百度加上换各种包尝试了四五次,发现添加compile 'org.apache.httpcomponents:httpcore:4.4.4'这个依赖之后,HttpRespone惊喜的可以用了。这个包导得有没有问题?
3、于是噼里啪啦打完代码,一运行,结果编译不过去,提示如下:
Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency commons-logging:commons-logging:1.2 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency commons-logging:commons-logging:1.2 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency commons-logging:commons-logging:1.2 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency org.apache.httpcomponents:httpclient:4.5.1 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages Warning:Dependency commons-logging:commons-logging:1.2 is ignored for release as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/codec/Decoder;
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Program Files\Java\jdk1.8\bin\java.exe'' finished with non-zero exit value 2
然后我彻底崩溃了!
我也知道这个错误的意思是这个包与androidSDK的内部版本冲突,但是你的内部版本不能用啊,我把compile 'org.apache.httpcomponents:httpclient-osgi:4.5.1'依赖删除之后立马报错,各种找不到类找不到方法。
我无数次实验,只有
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile 'org.apache.httpcomponents:httpclient-osgi:4.5.1'三个依赖全导才不报错
下图里面所有的apache的httpClient的依赖我通通导了个遍,并且所有排列组合都尝试过,两两搭配三三搭配,单独一个包。最后无解!
我自认为我真是拼了老命想靠自己来解决问题,但是喷了屏幕一口血,也没办法!希望大神帮帮我!