Error Message

我得到的错误信息是:
错误:失败:生成失败,出现异常。



我已经尝试将multidex设置为true,并按照类似博文中的说明从应用程序gradle中更改和删除行,但是构建仍然失败。

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
}

最佳答案

您的某些依赖项隐式依赖于支持库的不同版本,它们是:

implementation 'com.github.mirrajabi:search-dialog:1.1'
implementation 'com.github.AnyChart:AnyChart-Android:1.0.6'

尤其是使用以下支持库的搜索对话框:
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'

因此,您需要使用以下代码排除它们:
implementation ('com.github.mirrajabi:search-dialog:1.1') {
   exclude group: 'com.android.support'
   exclude module: 'appcompat-v7'
   exclude module: 'recyclerview-v7'
}

然后,您需要为所有依赖项提供相同版本的支持库。因此,更改以下内容:
compile 'com.android.support:support-annotations:27.1.1'


implementation 'com.android.support:support-annotations:26.1.0'

关于java - 无法合并Dex Android,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53733187/

10-09 10:04