首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未能合并Dex Android

未能合并Dex Android
EN

Stack Overflow用户
提问于 2018-12-11 22:18:23
回答 1查看 103关注 0票数 0

错误消息

给我的错误消息: Error:FAILURE: Build (异常)。

*出了什么问题:任务':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.执行失败 com.android.builder.dexing.DexArchiveMergerException: java.lang.RuntimeException:无法合并dex

我尝试过将multidex设置为true,并更改和删除应用程序gradle中的行,这在类似的帖子中已经解释过了,但是构建仍然失败。

代码语言:javascript
复制
apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-P'
    defaultConfig {
        applicationId "com.dheia.crypton"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

   }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-annotations:26.1.0'
    }
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
    //adding library for search
    implementation 'com.github.mirrajabi:search-dialog:1.1'
    compile 'com.android.support:support-annotations:27.1.1'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.github.AnyChart:AnyChart-Android:1.0.6'
    added dependency to Anycharts Git
}
EN

回答 1

Stack Overflow用户

发布于 2018-12-12 05:28:04

有些依赖项隐含地依赖于不同版本的支持库,如下所示:

代码语言:javascript
复制
implementation 'com.github.mirrajabi:search-dialog:1.1'
implementation 'com.github.AnyChart:AnyChart-Android:1.0.6'

特别是使用以下支持库的搜索对话框:

代码语言:javascript
复制
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'

因此,您需要使用以下代码排除它们:

代码语言:javascript
复制
implementation ('com.github.mirrajabi:search-dialog:1.1') {
   exclude group: 'com.android.support'
   exclude module: 'appcompat-v7'
   exclude module: 'recyclerview-v7'
}

然后,所有依赖项都需要相同版本的支持库。因此,更改以下内容:

代码语言:javascript
复制
compile 'com.android.support:support-annotations:27.1.1'

代码语言:javascript
复制
implementation 'com.android.support:support-annotations:26.1.0'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53733187

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档