首页 > 解决方案 > 为 Viger-PDF 添加依赖项时无法合并 dex 错误

问题描述

错误:任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'的执行失败

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

运行android项目时发生此错误。

添加依赖后:

implementation 'com.github.aerdy:Android-Viger_View_Pager_PDF_OpenSource:-SNAPSHOT'

应用程序.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
    applicationId "com.trinityinfosystem.kv.mycollege"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
   }
}

repositories {
    maven { url  "http://dl.bintray.com/lukaville/maven"}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.code.gson:gson:2.8.5'

implementation 'de.hdodenhof:circleimageview:2.2.0'

implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'

implementation 'com.github.bumptech.glide:glide:4.7.1'

implementation 'com.github.ittianyu:BottomNavigationViewEx:1.2.4'
implementation 'com.github.yalantis:Side-Menu.Android:1.0.1'

implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.facebook.android:audience-network-sdk:4.99.1'
implementation 'me.relex:circleindicator:1.2.2@aar'

implementation 'com.github.aerdy:Android-Viger_View_Pager_PDF_OpenSource:-SNAPSHOT'
}

标签: android

解决方案


只需将 defaultConfig multiDexEnabled true 和 minifyEnabled true 添加到 build.gradle(Module:app) 文件中,然后同步您的项目


推荐阅读