DexArchiveMergerException:合并dex存档时出错

时间:2018-11-19 06:11:04

标签: android exception merge archive dex

我遇到了dex合并错误。我正在使用Android Studio 3.2.1。这是更多模块。但是我想这些是产生错误的文件。我尝试更新无法正常运行的Google Play服务。

我有两个模块socket lib和iqsits lib。 iqsits库被添加到套接字库中。当我不在应用gradle中添加此代码时,运行代码会给我iqsits软件包未找到的错误。当我将其添加到应用程序gradle中时,代码会给我dex合并错误。

项目gradle:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.google.gms:google-services:3.2.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app gradle:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "com.intmilli.imobile"
        vectorDrawables.useSupportLibrary = true
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0.0.0"
        multiDexEnabled true
    }
    buildTypes {
        /* release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            debuggable true
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }*/
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    useLibrary 'org.apache.http.legacy'
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'app/assets/', 'assets/'] } }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }

    lintOptions {
        disable 'InvalidPackage'
    }
}


repositories {
    maven { url "https://jitpack.io" }
}

ext {
    supportLibraryVersion = '27.1.1'
    playServicesVersion = '11.0.4'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    // External project jar files
    implementation files('libs/mail.jar')
    implementation files('libs/activation.jar')
    implementation files('libs/additional.jar')
    //implementation files('libs/gson-2.3.1.jar')
    implementation project(':MPChartLib')
    implementation project(':iqsits_lib')
    implementation project(':socket_lib')
    implementation 'com.google.code.gson:gson:2.8.2'

    //Android support libs
    implementation "com.android.support:design:$supportLibraryVersion"
    implementation "com.android.support:cardview-v7:$supportLibraryVersion"
    implementation "com.android.support:recyclerview-v7:$supportLibraryVersion"
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    //Google play services libs
    implementation "com.google.android.gms:play-services-gcm:$playServicesVersion"
    implementation "com.google.android.gms:play-services-analytics:$playServicesVersion"
    //External service libs
    implementation 'com.mcxiaoke.volley:library:1.0.19'
    implementation 'com.fasterxml.jackson.core:jackson-core:2.7.3'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.7.3'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.7.3'
    //Custom views libs
    implementation 'com.astuetz:pagerslidingtabstrip:1.0.1'
    implementation 'com.balysv:material-ripple:1.0.2'
    implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
    implementation 'de.hdodenhof:circleimageview:1.2.1'
    //implementation 'com.qhutch.bottomsheetlayout:bottomsheetlayout:0.1.3'
    implementation 'com.github.castorflex.smoothprogressbar:library-circular:1.0.0'
    //firebase libraries
    implementation "com.google.firebase:firebase-auth:$playServicesVersion"
    implementation "com.google.firebase:firebase-config:$playServicesVersion"
    implementation 'org.aviran.cookiebar2:cookiebar2:1.0.9'
    implementation 'me.biubiubiu.justifytext:library:1.1'

    //imobile
    implementation 'com.github.ybq:Android-SpinKit:1.1.0'

    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:multidex:1.0.1'
}
apply plugin: 'com.google.gms.google-services'

socket libs模块:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    buildToolsVersion '27.0.3'


    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    implementation group: 'org.apache.mina', name: 'mina-core', version: '2.0.4'

    implementation project(path: ':iqsits_lib')
}

iqsits lib模块

apply plugin: 'com.android.library'

android {
    compileSdkVersion 28
    buildToolsVersion '27.0.3'

    defaultConfig {
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'org.java-websocket:Java-WebSocket:1.3.0'
}

2 个答案:

答案 0 :(得分:1)

您不需要在应用程序的build.gradle中添加iqsits_lib依赖项,因为socket_lib已经在依赖项列表中包含了它。如果您的主应用确实需要更改

implementation project(path: ':iqsits_lib')

api project(path: ':iqsits_lib')

在socket_lib的build.gradle文件中

答案 1 :(得分:0)

我收到合并错误,因为我的 multidex 没有启用。一旦我在 build.gradle 中将 multiDexEnabled 设置为 true,它就会消失。