相关疑难解决方法(0)

如何使用gradle构建文件从Android上的org.apache正确导入HttpClient?

当我尝试运行"gradle build"时,我看到了这个错误

WARNING: Dependency org.apache.httpcomponents:httpclient:4.2.3 is ignored for the default configuration as it may be conflicting with the internal version provided by Android.
         In case of problem, please repackage with jarjar to change the class packages
:prepareFreeDebugDependencies
:compileFreeDebugAidl UP-TO-DATE
:generateFreeDebugBuildConfig UP-TO-DATE
:mergeFreeDebugAssets UP-TO-DATE
:compileFreeDebugRenderscript UP-TO-DATE
:mergeFreeDebugResources UP-TO-DATE
:processFreeDebugManifest UP-TO-DATE
:processFreeDebugResources UP-TO-DATE
:compileFreeDebug
/home/xrdawson/Projects/Foo/Bar/src/main/java/com/Foo/app/PixActivity.java:20: error: package org.apache.http.entity.mime does not exist
import org.apache.http.entity.mime.HttpMultipartMode;
                              ^
Run Code Online (Sandbox Code Playgroud)

build.gradle的结尾如下所示:

    repositories {
        mavenCentral()
    }

    dependencies { 
        compile fileTree(dir: 'libs', include: '*.jar')
        compile "org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.3"
        compile "com.madgag:markdownj-core:0.4.1"
//      compile …
Run Code Online (Sandbox Code Playgroud)

android gradle apache-httpclient-4.x

38
推荐指数
3
解决办法
7万
查看次数

与Android软件包冲突 - 亚马逊SNS

我一直在尝试将Amazon SNS客户端与android项目集成.

我使用以下依赖命令包含库

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.amazonaws:aws-java-sdk-sns:1.10.+'
    compile 'com.google.android.gms:play-services:7.5.0'
}
Run Code Online (Sandbox Code Playgroud)

因此它自动包含上面的库(及其依赖项: aws_java_sdk_coreaws_java_sdk_sqs).所有3个库的版本均为 1.10.2.

问题是AWS核心有两个模块

  1. commons-logging(commons-logging:commons-logging:1.1.3)
  2. httpclient(org.apache.httpcomponents:httpclient:4.3.6)

由于android内部具有相同的包,因此它排除了这些模块以避免任何冲突.结果是当aws代码尝试从这些模块访问某些类时.Tt期待它的不同版本,找不到预期的方法,并使应用程序崩溃.

有没有办法覆盖android的排除?(或者有更好的方法来处理这种情况吗?)

编辑:添加了gradle日志:

WARNING: Dependency commons-logging:commons-logging:1.1.3 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.3.6 is ignored for debug as it may be conflicting with the internal version …
Run Code Online (Sandbox Code Playgroud)

java android amazon-web-services

8
推荐指数
1
解决办法
944
查看次数