首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多个dex文件定义Lcom/amazonaws/AmazonWebServiceClient;

多个dex文件定义Lcom/amazonaws/AmazonWebServiceClient;
EN

Stack Overflow用户
提问于 2015-07-21 08:34:45
回答 3查看 1.3K关注 0票数 2

我正试图在我的Android应用程序中使用Amazon。这个应用程序已经使用了C2Call SDK。该应用程序正在工作,但一旦我添加AWS级库,它就开始给我多个Dex文件异常。我搜索了它,并知道它与多次定义的单个库相关,但是我不确定日志中的是哪一个库。我尝试删除不同的gradle编译选项,每当我添加AWS库时,它就会给出多个Dex异常。

这是我的应用程序的分级文件-

代码语言:javascript
复制
apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.test.test"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    flatDir {
        dirs 'libs'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    /*compile 'com.android.support:appcompat-v7:22.2.0'*/
    compile(name: 'lib-c2callsdk', ext: 'aar')
    compile 'com.amazonaws:aws-android-sdk-cognito:2.2.3'
    compile 'com.amazonaws:aws-android-sdk-ses:2.2.3'
    compile 'com.amazonaws:aws-android-sdk-ddb:2.2.3'
}

我也试着添加和删除appcompact。

这是我得到的错误日志-

代码语言:javascript
复制
Information:Gradle tasks [:app:assembleDebug]
Warning:Dependency commons-logging:commons-logging:1.1.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.1.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
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareLibC2callsdkLibrary UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJava
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:preDexDebug
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$4) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$5) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.LogFactory$6) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.LogFactoryImpl$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.SimpleLog$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.WeakHashtable$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(com.amazonaws.services.s3.model.a.d) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/amazonaws/AmazonWebServiceClient;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
    at com.android.dx.command.dexer.Main.run(Main.java:246)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 25.398 secs
Information:1 error
Information:2 warnings
Information:See complete output in console

如果我只选择一个AWS库,比如定位,它就会在没有长警告的情况下提供相同的异常。

你知不知道我在这里做错了什么,怎么才能找到确切的问题?

更新:

我试过把下面的内容放进应用程序的等级-

代码语言:javascript
复制
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    /*compile 'com.android.support:appcompat-v7:22.2.0'*/
    compile(name: 'lib-c2callsdk', ext: 'aar'){
        exclude group:'gson'
        exclude group:'commons-logging'
    }
    compile ('com.amazonaws:aws-android-sdk-core:2.+'){
        exclude group:'gson'
        exclude group:'commons-logging'
    }
    /*compile 'com.amazonaws:aws-android-sdk-cognito:2.+'
    compile 'com.amazonaws:aws-android-sdk-ses:2.+'
    compile 'com.amazonaws:aws-android-sdk-ddb:2.+'*/
    /*compile 'com.google.code.gson:gson:2.3'*/
}

现在错误减少到-

代码语言:javascript
复制
Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareLibC2callsdkLibrary UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJava UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug UP-TO-DATE
:app:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/amazonaws/AmazonWebServiceClient;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
    at com.android.dx.command.dexer.Main.run(Main.java:246)
    at com.android.dx.command.dexer.Main.main(Main.java:215)
    at com.android.dx.command.Main.main(Main.java:106)
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 2
Information:BUILD FAILED
Information:Total time: 2.804 secs
Information:1 error
Information:0 warnings
Information:See complete output in console
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-07-22 00:25:56

错误说com.amazonaws.AmazonWebServiceClient是多次定义的。很可能在您的项目中引用了几个Android副本,其中一个显然来自Maven。请你再检查一遍,在libs文件夹下没有另一个?我不熟悉c2call。不确定其中是否存在与AWS冲突的内容。检查的一种方法是解压缩jars并搜索特定的类。下面是一个示例:

代码语言:javascript
复制
unzip -l *.jar | grep AmazonWebServiceClient

至于警告,你可以无视它。Android依赖1.1.1,它是用JDK1.5编译的。Android不喜欢它,但可以接受它。

票数 4
EN

Stack Overflow用户

发布于 2015-07-23 11:03:25

我做了些什么来解决这个问题(帮助那些将来可能需要的人)-

  1. 将AAR文件扩展名更改为zip并解压缩它。
  2. 打开解压缩文件夹以查找classes.jar
  3. 下载JarJar.jar
  4. 创建一个规则文件,您可以在其中提到需要重构的包或类。这是我的规则文件- 规则com.amazonaws.services.s3.a.* com.jarjar.@0规则com.amazonaws.services.s3.model.a.* com.jarjar.@0规则com.amazonaws.services.s3.model.* com.jarjar.@0规则com.amazonaws.services.s3.s3.* com.jarjar.@0规则com.amazonaws.sdk.* com.jarjar.@0规则com.amazonaws.regions.* com.jarjar.@规则com.amazonaws.services.s3.model.*com.jarjar@0规则com.amazonaws.javax.xml.stream.xerces.impl.msg.* com@0规则com.amazonaws.d*com.jarjar@0规则com.amazonaws.c*com.jarjar@com.jarjar@0规则com.amazonaws.a*com.jarjar@0规则com.amazonaws.auth*com.amazonaws.auth。@0规则com.amazonaws.auth。@0规则com.amazonaws.c*com.amazonaws.b*com.jarjar。@ com.amazon.device规则.messaging.development.* com.jarjar.@0规则com.amazon.device.Message.* com.jarjar.@0规则com.amazon.* com.jarjar.@0规则com.google.gson.stream.* com.jarjar.@0规则com.google.gson.refl.* com.jarjar.@0规则com.google.gson.bind.* com.jarjar.@0规则com.google.gson.inside.* com.jarjar.@0规则com.google.gson.com.jarjar.* com.jarjar.@0规则com.google.gson*com.jarjar@0
  5. 运行jarjar.jar。这是一个示例命令- java -jar“D:\Android\jarjar-1.4.jar”进程jarjarrules.txt lib-c2callsdk\classes.jar classes.jar
  6. 复制生成的classes.jar并将副本转换为zip。提取它以验证重构。
  7. 现在,复制生成的classes.jar,并在解压缩的库文件夹中替换旧的classes.jar。
  8. 将文件夹压缩为zip(请记住根目录上有classes.jar )。
  9. 将zip重命名为aar扩展。
  10. 在项目中使用新的aar库。

当然,感谢杨帆提出的解决方案。

票数 1
EN

Stack Overflow用户

发布于 2018-01-08 10:07:40

我正在使用AWS推理库进行图像识别。

我在使用

代码语言:javascript
复制
implementation 'com.amazonaws:aws-java-sdk-rekognition:1.11.66
implementation 'com.amazonaws:aws-android-sdk-core:2.4.4

在android中,我通过用jar文件替换依赖项jar文件来解决问题。

代码语言:javascript
复制
dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'

implementation 'com.amazonaws:aws-android-sdk-core:2.2.+'
implementation files('yourJarFileLocation/AmazonRekognition/lib/aws-android-sdk-rekognition-2.6.9.jar')

}

接下来就是打扫,重建,跑。啊,真灵

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31534073

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档