java – 与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'
}

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

问题是AWS核心有两个模块

> commons-logging(commons-logging:commons-logging:1.1.3)
> 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 provided by Android.
         In case of problem,please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.1.3 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.3.6 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

解决方法

您是否尝试排除存在冲突的依赖项?由于它们在两个库中都可用,因此您可以选择忽略它们,这应该可以正常工作.
dependencies {

        ...
        compile ('com.amazonaws:aws-java-sdk-sns:1.10.2') {
            exclude group: 'commons-logging',module: 'commons-logging'
        }
        compile ('com.amazonaws:aws-java-sdk-sns:1.10.2') {
            exclude group: 'org.apache.httpcomponents',module: 'httpclient'
        }
        ....
}

(我已经使用了用于排除的组和模块的指示性名称,您可以尝试使用确切的名称,认为它应该可以工作)

Very useful link that shows how to exclude using,Artifact name,module and both module & artifact.

Check this reference answer as well

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...