当前位置: 首页 > 知识库问答 >
问题:

当我尝试编译代码时,任务“:app:DexDebug”执行失败

黄英韶
2023-03-14

当我尝试编译代码时,我得到以下错误:

错误:任务“:app:DexDebug”执行失败。

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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.19.2'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://s3.amazonaws.com/repo.commonsware.com" }

}

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId "com.example.example"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 20012
        versionName '2.3.3'
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
            proguardFile '/My Workspace/FirstApp/proguard-android.txt'
            debuggable false
            multiDexEnabled true
        }
        debug {
            minifyEnabled false
            debuggable true
            proguardFile '/My Workspace/FirstApp/proguard-android.txt'
        }
    }
    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'LICENSE'
        exclude 'license.txt'
    }
    productFlavors {
    }
}

dependencies {
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.mcxiaoke.volley:library:1.0.18'
    compile 'com.google.code.gson:gson:2.3.1'
    compile files('libs/AF-Android-SDK-v2.3.1.17.jar')
    compile 'com.squareup.okio:okio:1.4.0'
    compile 'com.squareup.okhttp:okhttp:2.4.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:cardview-v7:22.2.1'
    compile 'com.android.support:recyclerview-v7:22.2.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:design:22.2.1'
    compile 'com.commonsware.cwac:anddown:0.2.+'
}

为google location services/gcm使用了单独的api库,并删除了完整的play service库。这减少了可靠的库方法和错误得到了解决。

共有1个答案

陆正奇
2023-03-14

它太笼统了,但是有几个原因导致您出现这个错误1。检查build.gradle中的依赖项{}。您所依赖的库必须重复。
更多详细信息:查看我的网站2。编译时在build.gradle中放大堆大小

android {
   ...
   dexOptions{
      incremental true
      javaMaxHeapSize "4g"
   }
}
 类似资料: