【问题标题】:java.lang.RuntimeException: com.andoid.builder.dexing.DexArchiveMergerException unable to merge dex [duplicate]java.lang.RuntimeException:com.andoid.builder.dexing.DexArchiveMergerException 无法合并 dex [重复]
【发布时间】:2018-01-18 16:36:47
【问题描述】:

我正在尝试构建一个可以访问 Spotify 的公共 API 的应用程序模型,而这些是我迄今为止使应用程序的服务和功能正常工作所需要的。 gradle 同步本身很好,但是当我尝试构建项目时,我遇到了这个问题:

错误:任务执行失败 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'。 java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并 索引

我尝试过的事情:

  1. 从菜单清理和重建项目
  2. 在 gradle 中启用 multidex

multiDexEnabled true
  1. 确保不同的依赖关系不会在 gradle 中重复

我在 MacOS Sierra 10.12.6 上的 Android Studio 3 上运行。

这是我的毕业典礼:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.example.mostags.trial5"
        minSdkVersion 25
        targetSdkVersion 26
        versionCode 1
        versionName "1.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main {
            java.srcDirs = ['src/main/java', 'src/main/java/com.example.mostags.trial5/methods']
        }
    }
}

repositories {
    google()

    jcenter()
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
    maven { url 'https://github.com/thelinmichael/spotify-web-api-java' }
}

android {
    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
        resolutionStrategy.force 'com.google.android.gms:play-services:11.2.2'
    }
}


dependencies {
    compile 'com.android.support:multidex:1.0.2'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile('com.jayway.jsonpath:json-path:2.0.0') {
        exclude group: 'net.minidev', module: 'asm'
    }

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'


    compile('com.amazonaws:aws-android-sdk-mobile-client:2.6.7@aar') { transitive = true; }
    compile('com.amazonaws:aws-android-sdk-auth-userpools:2.6.+@aar') { transitive = true; }
    compile('com.amazonaws:aws-android-sdk-auth-ui:2.6.+@aar') { transitive = true; }

    compile 'net.sf.json-lib:json-lib:2.4:jdk15'

    compile 'com.google.guava:guava:23.6-android'
    compile 'com.google.protobuf:protobuf-java:3.5.1'
    compile 'com.google.protobuf:protobuf-lite:3.0.1'
    compile 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'

    compile('se.michaelthelin.spotify:spotify-web-api-java:1.5.0') {
        exclude group: "commons-beanutils", module: "commons-beanutils"

    }
    compile 'commons-beanutils:commons-beanutils:20030211.134440'
    compile 'commons-codec:commons-codec:1.11'

    compile 'org.apache.httpcomponents:httpcore:4.4.8'
    compile 'org.apache.httpcomponents:httpclient:4.5.4'

    android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true;

    compile fileTree(include: ['*.jar'], dir: 'libs')

    //these two lines are added
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.2.0'

    // This library handles authentication and authorization
    compile 'com.spotify.android:auth:1.0.0-alpha'

}

【问题讨论】:

标签: java android android-studio


【解决方案1】:

试试这个

multiDexEnabled = true

【讨论】:

  • 我已经尝试过了,但仍然有同样的错误,这是我尝试的第一个修复,但不幸的是它没有修复任何问题。不过还是谢谢你的建议。
猜你喜欢
  • 2018-08-09
  • 2018-11-10
  • 1970-01-01
  • 2018-04-24
  • 1970-01-01
  • 2018-05-05
  • 2019-01-08
  • 2018-08-06
  • 2018-02-26
相关资源
最近更新 更多