This question already has answers here:
Android support multidex library implementation

(4个答案)


2年前关闭。




生成带签名的apk时,出现此错误,但是构建项目正常

错误:将字节码转换为dex时出错:
原因:com.android.dex.DexException:多个dex文件定义了Landroid / support / v4 / accessibilityservice / AccessibilityServiceInfoCompat;

gradle:
apply plugin: 'com.android.application'

repositories {
    maven {
        url 'https://raw.github.com/71241NW123CK/maven-repo/master'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.baclock"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 18
        versionName "2018.02.09"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        incremental false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'party.treesquaredcode.android:flip-animation:0.0.2'
    compile 'com.mcxiaoke.volley:library:1.0.6'
    compile 'com.google.android.gms:play-services-gcm:8.1.0'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile 'com.evernote:android-job:1.2.4'
}

apply plugin: 'com.google.gms.google-services'

最佳答案

在默认配置中添加multiDexEnabled true,然后尝试。

defaultConfig {
        applicationId "com.baclock"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 18
        versionName "2018.02.09"
        multiDexEnabled true
    }

07-24 09:48
查看更多