java - 与 android 包冲突 - Amazon SNS

标签 java android amazon-web-services

我一直在尝试将 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_coreaws_java_sdk_sqs)。所有 3 个库的版本均为 1.10.2

问题是AWS核心有两个模块

  1. 公共(public)日志记录(公共(public)日志记录:公共(public)日志记录:1.1.3)
  2. http客户端(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

最佳答案

由于您正在从事 Android 项目,请考虑使用 AWS SDK for Android .它针对 Android 平台进行了优化。它具有更小的库、更少的依赖项和其他优化。它应该解决冲突的问题。查看developer guide .

就像更新依赖项以编译“com.amazonaws:aws-android-sdk-sns:2.2.+”一样简单。其用法应与Java SDK兼容。

关于java - 与 android 包冲突 - Amazon SNS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31236473/

相关文章:

用于在多个嵌套循环中验证数据的 Java 8 替代方案

php - 亚马逊 SES 错误

java - 为什么我不能在 ormlite 中使用自定义 DAO 类?

android - 将位置转换为 LatLng

android - 在 Android 中解除绑定(bind)后,如何让服务与听众保持联系?

amazon-web-services - Kinesis 保证交付吗?

api - 未记录的 AWS TAG_FILTERS_1_0

java - 如何删除JMenu Items中的空格

java - BigDecimal 的未缩放值是多少?

java - 在命令提示符下运行时图像出现 NullPointerException