gradle构建错误:app:dexDebug

时间:2015-04-08 16:20:33

标签: android gradle

我想开始申请" app" ,我在构建gradle时遇到错误:

  

错误:任务':app:dexDebug'执行失败。    com.android.ide.common.internal.LoggedErrorException:无法运行命令:       C:\ Users \ jaafar \ AppData \ Local \ Android \ sdk \ build-tools \ 21.1.2 \ dx.bat --dex --no-optimize --output C:\ Users \ jaafar \ AndroidStudioProjects \ helooandroidstudio \ app \ build \ intermediates \ dex \ debug --input-list = C:\ Users \ jaafar \ AndroidStudioProjects \ helooandroidstudio \ app \ build \ intermediates \ tmp \ dex \ debug \ inputList.txt   错误代码:       2   输出:       意外的顶级例外情况:       com.android.dex.DexException:多个dex文件定义Lcom / facebook / AccessToken $ 1;           在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:303)           在com.android.dx.command.dexer.Main.run(Main.java:246)           在com.android.dx.command.dexer.Main.main(Main.java:215)           在com.android.dx.command.Main.main(Main.java:106)

这是我的 build.gradle

apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

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

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:+'
compile 'com.vk:androidsdk:+'
compile 'org.altbeacon:android-beacon-library:2+@aar'
compile 'com.mcxiaoke.volley:library:1.+'
compile project(':reco-sdk-android_0.1.55')
compile project(':reco-sdk-android_0.1.5_JavaDoc')
compile project(':facebook')
 }

这是我更新的build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "com.heloo"
    minSdkVersion 9
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
   dexOptions { 
   preDexLibraries = false 
  }
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:+'
compile 'com.vk:androidsdk:+'
compile 'org.altbeacon:android-beacon-library:2+@aar'
compile 'com.mcxiaoke.volley:library:1.+'
compile project(':reco-sdk-android_0.1.55')
compile project(':reco-sdk-android_0.1.5_JavaDoc')
compile project(':facebook')

}

2 个答案:

答案 0 :(得分:1)

我打算将其作为答案而不是评论发布

您应该将此代码添加到build.gradle

dexOptions { 

preDexLibraries = false }

答案 1 :(得分:1)

它已修复,我的问题不在 build.gradle ,我的应用程序在依赖项中包含2个冲突模块依赖项(2 facebook模块),我保留了我使用的那个并删除了其他它正在工作!谢谢你们任何方式