本文介绍了在Android Studio中错误:执行失败的任务“:应用程序:dexDebug”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我在Twitter整合工作的(登录与Twitter)的有面料插件在Android Studio中1.1.0

Here i am work on twitter integration (login with twitter) with "Fabric Plugin" in android studio 1.1.0

错误:执行失败的任务:应用程序:dexDebug。

com.android.ide.common.internal.LoggedErrorException:无法运行命令:
      /home/dhruv/Dhruv/sdk/build-tools/21.0.2/dx --dex --no-优化--output /家庭/ Dhruv直升机/ FestEvo /应用程序/编译/中间体/ DEX /调试--input列表= /家庭/ Dhruv直升机/ FestEvo /应用程序/编译/中间体/ tmp目录/ DEX /调试/ inputList.txt
    错误code:
      2
    输出:
      意外的顶级例外:
      com.android.dex.DexException:多DEX文件定义LCOM /谷歌/ GSON / JsonSerializer;
          在com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
          在com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
          在com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
          在com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
          在com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
          在com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
          在com.android.dx.command.dexer.Main.runMonoDex(Main.java:302)
          在com.android.dx.command.dexer.Main.run(Main.java:245)
          在com.android.dx.command.dexer.Main.main(Main.java:214)
          在com.android.dx.command.Main.main(Main.java:106)

这是的的build.gradle:的文件

This is build.gradle: file

buildscript {
    repositories {
       // jcenter()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.+'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories{
    flatDir{
        dirs 'libs'
    }
    //jcenter()
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.0.2"

    defaultConfig {
        applicationId "com.festevo.devtesting"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

configurations {
    all*.exclude group: 'com.android.support', module: 'support-v4'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    //compile 'com.android.support:appcompat-v7:21.0.3'

    //compile 'com.spotify.sdk:spotifysdk:1.0.0-beta6@aar'
    compile 'com.spotify.sdk:spotifysdk:1.0.0-beta8@aar'
    // NOTE: Version must match!
   // compile 'com.android.support:support-v4:+'

    compile project ('libraries:FacebookSDK')
    compile project ('libraries:simple-crop-image-lib')
    compile project ('libraries:SlidingMenu')
    compile project ('libraries:nineoldandroids')
    compile project ('libraries:google-play-services_lib')
    compile('com.twitter.sdk.android:twitter:1.3.2@aar') {
        transitive = true;
    }

}

请建议我如何解决我感谢你的问题提前:)

Please suggest me how to solve my problem thanks you in advance:)

推荐答案

有了这个错误也是如此。关键是在这里:多个DEX文件定义LCOM /谷歌/ GSON / JsonSerializer;

Had this error as well. The key is here: "Multiple dex files define Lcom/google/gson/JsonSerializer;"

最有可能你是在引用您的应用程序GSON的多个版本。所以,你可以右键点击你的项目模块 - >打开模块设置 - >依赖性选项卡,并删除任何额外GSON版本

Most likely you are referencing more than one version of gson in your app. So you can right click on your Project Module -> Open Module Settings -> Dependencies tab and any remove any extra gson versions.

如果你想有一个更清晰的画面,你可以进入Android Studio中端,做grep的-r GSON看到所有的引用。

If you want a clearer picture, you can go into terminal in Android Studio and do grep -r gson to see all references.

这篇关于在Android Studio中错误:执行失败的任务“:应用程序:dexDebug”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 17:42