简体   繁体   English

Android:添加的依赖关系使Gradle中出现DEX错误。

[英]Android : Dependency added gives DEX error in Gradle.

I am working on an Android application in which i am trying to get Cometd(Push technology) working. 我正在尝试在其中运行Cometd(推送技术)的Android应用程序。 For that I added some Gradle dependencies, but I am getting a DEX error. 为此,我添加了一些Gradle依赖项,但出现了DEX错误。 How can I resolve this? 我该如何解决?

Error log : 错误日志:

Total time: 2.742 secs
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72200Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72211Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42221Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet750Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable750Library UP-TO-DATE
:app:prepareComTonicartosSuperslim0413Library 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:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl UP-TO-DATE
:app:processDebugAndroidTestManifest UP-TO-DATE
:app:compileDebugAndroidTestRenderscript UP-TO-DATE
:app:generateDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets UP-TO-DATE
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources UP-TO-DATE
:app:mergeDebugAndroidTestResources UP-TO-DATE
:app:processDebugAndroidTestResources UP-TO-DATE
:app:generateDebugAndroidTestSources UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:preDexDebug
:app:dexDebug
AGPBI: {"kind":"simple","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","sources":[{}]}
AGPBI: {"kind":"simple","text":"com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:246)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:215)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.Main.main(Main.java:106)","sources":[{}]}


 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 2

* 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: 1 mins 5.571 secs

app.build : app.build:

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.fasterxml.jackson.core:jackson-core:2.6.0'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.6.0'
    compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
    compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
    compile('org.springframework.android:spring-android-auth:1.0.1.RELEASE') {
        exclude group: 'org.springframework', module: 'commons-logging'
        exclude group: 'org.springframework', module: 'spring-core'
        exclude group: 'org.springframework', module: 'spring-web'
    }
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.6.0'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.tonicartos:superslim:0.4.13'
    compile 'commons-codec:commons-codec:1.9'
    compile 'com.squareup.picasso:picasso:2.5.2'

// I added the below ones and then it started giving error

    compile 'org.cometd.java:bayeux-api:3.0.4'
    compile 'org.cometd.java:cometd-java-server:3.0.4'
    compile 'org.cometd.java:cometd-java-client:3.0.4'
    compile 'org.cometd.java:cometd-java-annotations:3.0.4'
}


android {
    compileSdkVersion 'Google Inc.:Google APIs:22'
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "com.notes"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
//        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

    /*dexOptions {
        javaMaxHeapSize "4g"
    }*/
}

Kindly let me know what I should do. 请让我知道我应该怎么做。 Thanks a lot. 非常感谢。 :-) :-)

defaultConfig {
         minSdkVersion 14 //lower than 14 doesn't support multidex
         targetSdkVersion 22

         // Enabling multidex support.
         multiDexEnabled true
     }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Studio IDE致命错误-“插件Gradle中的异常”。 - Android Studio IDE Fatal Error - “Exception in plugin Gradle.” Android 给出错误“无法将请求的类放入单个 dex 文件” - Android gives error "Cannot fit requested classes in a single dex file" CircleCI 找不到 gradle。 错误:./gradlew:没有这样的文件或目录 - CircleCI cannot find gradle. Error: ./gradlew: No such file or directory Javafxports android dex错误 - Javafxports android dex error Gradle 构建错误将字节码转换为 dex 时出错:原因:com.android.dex.DexException:多个 dex 文件定义 Landroid/arch/lifecycle/liveData$1 - Gradle build error Error converting bytecode to dex:Cause: com.android.dex.DexException:Multiple dex files define Landroid/arch/lifecycle/liveData$1 Gradle:依赖关系未添加到类路径 - Gradle : Dependency not getting added to classpath Gradle 编译依赖项未添加到类路径中 - Gradle compile dependency is not added to classpath 检查是否在gradle中正确添加了依赖项 - Check if a dependency is correctly added in gradle "Android Gradle 错误“Gradle 的依赖项缓存可能已损坏”" - Android Gradle Error " Gradle's dependency cache may be corrupt " 使用Gradle将Facebook SDK添加到android studio项目中。 清单合并失败错误即将到来。 多个支持库冲突。 该怎么办? - Adding Facebook SDK to android studio project using Gradle. Manifest merger failed error coming. Multiple support libraries conflict. What to do?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM