添加一些依赖项后无法合并dex

时间:2018-03-15 15:33:47

标签: java android merge dex

我正在使用广告服务Appodeal。 Here是安装常见问题解答。

我收到了错误

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
  

java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex

添加到我的gradle后

implementation 'com.android.support:design:26.1.0'

这是我的Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.hereismyappid"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }


    packagingOptions {
        exclude 'publicsuffixes.gz'
    }

}
repositories {
    jcenter()
    flatDir {
        dirs 'libs'
    }
}



dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'


    implementation 'com.google.android.gms:play-services-ads:11.8.0'
    implementation 'com.google.android.gms:play-services-location:11.8.0'
    implementation name: 'adcolony-sdk-3.2.1', ext: 'aar'
    implementation name: 'mmedia-6.4.0', ext: 'aar'
    implementation name: 'mobvista_alphab', ext: 'aar'
    implementation name: 'mobvista_appwall', ext: 'aar'
    implementation name: 'mobvista_appwallext', ext: 'aar'
    implementation name: 'mobvista_common', ext: 'aar'
    implementation name: 'mobvista_interstitial', ext: 'aar'
    implementation name: 'mobvista_mvdownloads', ext: 'aar'
    implementation name: 'mobvista_mvjscommon', ext: 'aar'
    implementation name: 'mobvista_mvnative', ext: 'aar'
    implementation name: 'mobvista_nativeex', ext: 'aar'
    implementation name: 'mobvista_offerwall', ext: 'aar'
    implementation name: 'mobvista_playercommon', ext: 'aar'
    implementation name: 'mobvista_reward', ext: 'aar'
    implementation name: 'mobvista_videocommon', ext: 'aar'
    implementation name: 'mobvista_videofeeds', ext: 'aar'
   // implementation 'com.android.support:design:26.1.0' -- error 
}

我尝试了什么:

  1. 清洁&重建
  2. 删除.gradle
  3. 那么我需要做什么?

1 个答案:

答案 0 :(得分:0)

com.android.support:design:26.1.0 lib有所依赖:

1)com.android.support:animated-vector-drawable:26.1.0
2)com.android.support:appcompat-v7:26.1.0
3)com.android.support:recyclerview-v7:26.1.0
4)com.android.support:support-annotations:26.1.0
5)com.android.support:support-v4:26.1.0
6)com.android.support:support-vector-drawable:26.1.0

你不应该两次添加这些库。删除重复的依赖项并检查项目中的/ libs文件夹。