合并dex档案时出现Android错误

时间:2018-04-01 06:12:32

标签: android android-studio android-gradle build.gradle

更新我的android工作室和构建工具版本后得到此错误。我已尝试通过互联网解决此问题的所有解决方案,但未成功 不知道为什么会这样???

  

Android studio版本:3.1

     

Gradle版本“:4.4

     

Gradle插件:3.1

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

我的build.gradle文件

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.abc.abc"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true //Tryed this but not worked
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    repositories {
        maven {
            url 'https://github.com/jitsi/jitsi-maven-repository/raw/master/releases'
        }
//    maven { url "https://dl.bintray.com/michelelacorte/maven/" }
        mavenCentral()
    }
    configurations {
        all*.exclude module: 'support-v4'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.android.support:support-fragment:27.1.0'
    // multipart entity
    implementation('org.apache.httpcomponents:httpmime:4.+') {
        exclude module: "httpclient"
    }
    implementation 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
    //    implementation 'com.wonderkiln:camerakit:0.13.0'
    implementation 'com.getbase:floatingactionbutton:1.10.1'
    implementation 'org.jitsi.react:jitsi-meet-sdk:1.9.0'
    //    compile 'com.google.code.gson:gson:2.2.4'
    //    compile 'com.android.support:support-emoji:26.0.1'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    implementation 'com.android.volley:volley:1.1.0'
    implementation 'com.miguelcatalan:materialsearchview:1.4.0'
    implementation 'com.yalantis:ucrop:2.2.0-native'
    implementation 'com.pnikosis:materialish-progress:1.7'
    implementation 'org.igniterealtime.smack:smack-android-extensions:4.2.0'
    implementation 'org.igniterealtime.smack:smack-experimental:4.2.0'
    implementation 'org.igniterealtime.smack:smack-tcp:4.2.0'
    implementation 'org.apache.commons:commons-lang3:3.4'
    implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
    implementation 'com.googlecode.libphonenumber:libphonenumber:7.0.4'
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'com.google.android.gms:play-services-places:11.8.0'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    implementation 'com.github.bumptech.glide:glide:4.6.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
    implementation 'com.eyalbira.loadingdots:loading-dots:1.0.2'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    // implementation 'com.google.android.exoplayer:exoplayer:2.7.1'
    //    compile 'it.michelelacorte.swipeablecard:library:2.3.0@aar'{
    //        exclude module: 'appcompat-v7'
    //        exclude group: 'com.android.support'
    //    }
    // BUTTER KNIFE
    implementation('com.jakewharton:butterknife:8.5.1') {
        exclude module: 'appcompat-v7'
        exclude group: 'com.android.support'
    }
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
    //    implementation project(':libemoji')
    implementation 'com.android.support:support-v13:27.1.0'
}

这几乎是我10天的浪费...... 最令人困惑的错误......

2 个答案:

答案 0 :(得分:1)

如果您的代码有两个不同的{strong>模块 google-play-servicessupport-v4使用这些库的不同版本,则会发生此错误。 检查您在项目中使用的库的依赖关系或使用

gradle app:dependencies

查看项目的依赖关系树,然后当您找到使用不同版本的库时,使用正确的版本将其添加到依赖项中。例如,如果您的依赖项中出现google-play-services:location:11.2.0,请将其替换为google-play-services:location:11.8.0

通常,您会在build.gradle文件中看到警告或错误消息(例如,在这种情况下,一个依赖项将标有红色下划线,表明它会导致版本不匹配)。

答案 1 :(得分:0)

在我的情况下,项目和模块的软件包名称相同。在调试模式下运行时,一切正常。但是当我想构建发布模式时。我得到这个错误。重命名程序包名称是我的解决方法。