将AppCompat v7添加到gradle会在编译时创建multipledex错误

时间:2015-10-04 14:52:10

标签: java android dex

我添加了AppCombatActivity v7 23.这产生了一些错误,我将它们整理出来。但是在运行应用程序时,我收到了多个dex错误 -

  

com.android.dex.DexException:多个dex文件定义   Landroid /支撑/注解/ AnimRes;

到目前为止,我所做的一切都没有用 -

  1. 从SDK中删除注释jar。
  2. 删除v4 android-support-v4.jar
  3. 当我从gradle中删除compile语句时,代码会编译。

    这是我的傻瓜 -

    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
        compile 'com.github.deano2390:MaterialShowcaseView:1.0.5@aar'
        compile 'com.android.support:appcompat-v7:23.0.1'
    }
    

    PS - 甚至用22.0。+

    编译

    整个错误报告 -

        Information:Gradle tasks [:assembleDebug]
    :preBuild UP-TO-DATE
    :preDebugBuild UP-TO-DATE
    :checkDebugManifest
    :preReleaseBuild UP-TO-DATE
    :prepareComAndroidSupportAppcompatV72301Library UP-TO-DATE
    :prepareComAndroidSupportSupportV42301Library UP-TO-DATE
    :prepareComGithubDeano2390MaterialShowcaseView105Library UP-TO-DATE
    :prepareDebugDependencies
    :compileDebugAidl UP-TO-DATE
    :compileDebugRenderscript UP-TO-DATE
    :generateDebugBuildConfig UP-TO-DATE
    :generateDebugAssets UP-TO-DATE
    :mergeDebugAssets UP-TO-DATE
    :generateDebugResValues UP-TO-DATE
    :generateDebugResources UP-TO-DATE
    :mergeDebugResources UP-TO-DATE
    :processDebugManifest UP-TO-DATE
    :processDebugResources UP-TO-DATE
    :generateDebugSources UP-TO-DATE
    :processDebugJavaRes UP-TO-DATE
    :compileDebugJava
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    :compileDebugNdk UP-TO-DATE
    :compileDebugSources
    :preDexDebug
    :dexDebug
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;
        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 ':dexDebug'.
    > com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_20\bin\java.exe'' finished with non-zero exit value 2
    Information:BUILD FAILED
    Information:Total time: 19.656 secs
    Information:1 error
    Information:0 warnings
    Information:See complete output in console
    

    我也跑了gradlew。这是日志 -

    Unzipping C:\Users\Sanved\.gradle\wrapper\dists\gradle-2.4-all\3i2gobhdl0fm2tosnn15g540i0\gradle-2.4-all.zip to C:\Users\Sanved\.gradle\wrapper\dists\gradle-2.4-all\3i2gobhdl0fm2tosnn15g540i0
    Download https://repo1.maven.org/maven2/com/android/tools/build/gradle/1.2.3/gradle-1.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/build/gradle-core/1.2.3/gradle-core-1.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/build/builder/1.2.3/builder-1.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/lint/lint/24.2.3/lint-24.2.3.pom
    Download https://repo1.maven.org/maven2/net/sf/proguard/proguard-gradle/5.1/proguard-gradle-5.1.pom
    Download https://repo1.maven.org/maven2/net/sf/proguard/proguard-parent/5.1/proguard-parent-5.1.pom
    Download https://repo1.maven.org/maven2/com/android/tools/build/builder-model/1.2.3/builder-model-1.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/build/builder-test-api/1.2.3/builder-test-api-1.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/sdklib/24.2.3/sdklib-24.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/sdk-common/24.2.3/sdk-common-24.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/common/24.2.3/common-24.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/build/manifest-merger/24.2.3/manifest-merger-24.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/ddms/ddmlib/24.2.3/ddmlib-24.2.3.pom
    Download https://repo1.maven.org/maven2/com/squareup/javawriter/2.5.0/javawriter-2.5.0.pom
    Download https://repo1.maven.org/maven2/org/sonatype/oss/oss-parent/7/oss-parent-7.pom
    Download https://repo1.maven.org/maven2/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.pom
    Download https://repo1.maven.org/maven2/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.pom
    Download https://repo1.maven.org/maven2/org/ow2/asm/asm/5.0.3/asm-5.0.3.pom
    Download https://repo1.maven.org/maven2/org/ow2/asm/asm-parent/5.0.3/asm-parent-5.0.3.pom
    Download https://repo1.maven.org/maven2/org/ow2/ow2/1.3/ow2-1.3.pom
    Download https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/5.0.3/asm-tree-5.0.3.pom
    Download https://repo1.maven.org/maven2/com/google/code/gson/gson/2.2.4/gson-2.2.4.pom
    Download https://repo1.maven.org/maven2/com/android/tools/lint/lint-checks/24.2.3/lint-checks-24.2.3.pom
    Download https://repo1.maven.org/maven2/org/eclipse/jdt/core/compiler/ecj/4.4/ecj-4.4.pom
    Download https://repo1.maven.org/maven2/net/sf/proguard/proguard-base/5.1/proguard-base-5.1.pom
    Download https://repo1.maven.org/maven2/com/android/tools/annotations/24.2.3/annotations-24.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/layoutlib/layoutlib-api/24.2.3/layoutlib-api-24.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/dvlib/24.2.3/dvlib-24.2.3.pom
    Download https://repo1.maven.org/maven2/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom
    Download https://repo1.maven.org/maven2/org/apache/commons/commons-parent/33/commons-parent-33.pom
    Download https://repo1.maven.org/maven2/org/apache/apache/13/apache-13.pom
    Download https://repo1.maven.org/maven2/org/apache/httpcomponents/httpclient/4.1.1/httpclient-4.1.1.pom
    Download https://repo1.maven.org/maven2/org/apache/httpcomponents/httpcomponents-client/4.1.1/httpcomponents-client-4.1.1.pom
    Download https://repo1.maven.org/maven2/org/apache/httpcomponents/project/4.1.1/project-4.1.1.pom
    Download https://repo1.maven.org/maven2/org/apache/httpcomponents/httpmime/4.1/httpmime-4.1.pom
    Download https://repo1.maven.org/maven2/org/apache/httpcomponents/httpcomponents-client/4.1/httpcomponents-client-4.1.pom
    Download https://repo1.maven.org/maven2/com/google/guava/guava/17.0/guava-17.0.pom
    Download https://repo1.maven.org/maven2/com/google/guava/guava-parent/17.0/guava-parent-17.0.pom
    Download https://repo1.maven.org/maven2/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.pom
    Download https://repo1.maven.org/maven2/com/android/tools/lint/lint-api/24.2.3/lint-api-24.2.3.pom
    Download https://repo1.maven.org/maven2/org/ow2/asm/asm-analysis/5.0.3/asm-analysis-5.0.3.pom
    Download https://repo1.maven.org/maven2/org/apache/httpcomponents/httpcore/4.1/httpcore-4.1.pom
    Download https://repo1.maven.org/maven2/org/apache/httpcomponents/httpcomponents-core/4.1/httpcomponents-core-4.1.pom
    Download https://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
    Download https://repo1.maven.org/maven2/org/apache/commons/commons-parent/5/commons-parent-5.pom
    Download https://repo1.maven.org/maven2/org/apache/apache/4/apache-4.pom
    Download https://repo1.maven.org/maven2/commons-codec/commons-codec/1.4/commons-codec-1.4.pom
    Download https://repo1.maven.org/maven2/org/apache/commons/commons-parent/11/commons-parent-11.pom
    Download https://repo1.maven.org/maven2/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.pom
    Download https://repo1.maven.org/maven2/com/android/tools/build/gradle/1.2.3/gradle-1.2.3.jar
    Download https://repo1.maven.org/maven2/com/android/tools/build/gradle-core/1.2.3/gradle-core-1.2.3.jar
    Download https://repo1.maven.org/maven2/com/android/tools/build/builder/1.2.3/builder-1.2.3.jar
    Download https://repo1.maven.org/maven2/com/android/tools/lint/lint/24.2.3/lint-24.2.3.jar
    Download https://repo1.maven.org/maven2/net/sf/proguard/proguard-gradle/5.1/proguard-gradle-5.1.jar
    Download https://repo1.maven.org/maven2/com/android/tools/build/builder-model/1.2.3/builder-model-1.2.3.jar
    Download https://repo1.maven.org/maven2/com/android/tools/build/builder-test-api/1.2.3/builder-test-api-1.2.3.jar
    Download https://repo1.maven.org/maven2/com/android/tools/sdklib/24.2.3/sdklib-24.2.3.jar
    Download https://repo1.maven.org/maven2/com/android/tools/sdk-common/24.2.3/sdk-common-24.2.3.jar
    Download https://repo1.maven.org/maven2/com/android/tools/common/24.2.3/common-24.2.3.jar
    Download https://repo1.maven.org/maven2/com/android/tools/build/manifest-merger/24.2.3/manifest-merger-24.2.3.jar
    Download https://repo1.maven.org/maven2/com/android/tools/ddms/ddmlib/24.2.3/ddmlib-24.2.3.jar
    Download https://repo1.maven.org/maven2/com/squareup/javawriter/2.5.0/javawriter-2.5.0.jar
    Download https://repo1.maven.org/maven2/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.jar
    Download https://repo1.maven.org/maven2/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.jar
    Download https://repo1.maven.org/maven2/org/ow2/asm/asm/5.0.3/asm-5.0.3.jar
    Download https://repo1.maven.org/maven2/org/ow2/asm/asm-tree/5.0.3/asm-tree-5.0.3.jar
    Download https://repo1.maven.org/maven2/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar
    Download https://repo1.maven.org/maven2/com/android/tools/lint/lint-checks/24.2.3/lint-checks-24.2.3.jar
    Download https://repo1.maven.org/maven2/org/eclipse/jdt/core/compiler/ecj/4.4/ecj-4.4.jar
    Download https://repo1.maven.org/maven2/net/sf/proguard/proguard-base/5.1/proguard-base-5.1.jar
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    A problem occurred configuring root project 'AIVVA'.
    > Could not resolve all dependencies for configuration ':classpath'.
       > Could not download proguard-base.jar (net.sf.proguard:proguard-base:5.1)
          > Could not get resource 'https://repo1.maven.org/maven2/net/sf/proguard/proguard-base/5.1/proguard-base-5.1.jar'.
             > Failed to move file 'C:\Users\Sanved\AppData\Local\Temp\gradle_download7702719224180984692bin' into filestore at 'C:\Users\Sanved\.gradle\caches\modules-2\files-2.1\net.sf.proguard\proguard-base\5.1\dc606dd778fe4685be16d5a171782ccfe0ef5637\proguard-base-5.1.jar'
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    
    BUILD FAILED
    
    Total time: 10 mins 0.155 secs
    

2 个答案:

答案 0 :(得分:1)

MaterialShowCaseView已经有了appcompat-v7。

你应该在build.gradle中将它排除在外:

{
    "name": "Run",
    "cmd": ["./YorickTheSavant"],
    "env" : { "LD_LIBRARY_PATH" : "/home/dan/SFML-2.3.1/lib" }
}

答案 1 :(得分:1)

您可以使用以下命令检查项目的依赖关系。 ./gradlew youtProjectName:dependencies

此命令告诉您哪个是依赖树,在您的情况下,知道哪些依赖项正在重复是很有用的。您的libs文件夹

中可能还有一些重复的依赖项